如何配置嵌入式 glassfish 3.1 以使用 JNDI 的替代端口 3700

发布于 2024-11-09 17:58:51 字数 751 浏览 4 评论 0原文

我有一个测试成功地使用嵌入式 glassfish 来测试 JCA 的部署。

但是,与已使用端口 3700 的 GlassFish 2.1 的运行版本存在冲突。

如何将嵌入式 GlassFish 对象配置为使用命名服务的替代端口?理想情况下,这可以在测试中进行配置。

这是当前的测试代码,

    GlassFishRuntime gfRuntime = GlassFishRuntime.bootstrap();
    GlassFish glassfish = gfRuntime.newGlassFish();
    glassfish.start();

    deployJca(glassfish);

    // Do tests on object acquired from JNDI.

    glassfish.stop();
    gfRuntime.shutdown();

例外的是,

Caused by: org.omg.CORBA.COMM_FAILURE: SEVERE: IOP00410016: Unable to create IIOP listener on the specified host all interfaces and port 3,700  vmcid: OMG  minor code: 16  completed: No
Caused by: java.net.BindException: Address already in use: bind

I have a test that is successfully using embedded glassfish to test the deployment of a JCA.

However there is conflict with the running version of GlassFish 2.1 which is already using port 3700.

How can the embedded GlassFish object be configured to use an alternative port for the naming service? Ideally this could be configured from within the test.

This is the current test code,

    GlassFishRuntime gfRuntime = GlassFishRuntime.bootstrap();
    GlassFish glassfish = gfRuntime.newGlassFish();
    glassfish.start();

    deployJca(glassfish);

    // Do tests on object acquired from JNDI.

    glassfish.stop();
    gfRuntime.shutdown();

The exception is,

Caused by: org.omg.CORBA.COMM_FAILURE: SEVERE: IOP00410016: Unable to create IIOP listener on the specified host all interfaces and port 3,700  vmcid: OMG  minor code: 16  completed: No
Caused by: java.net.BindException: Address already in use: bind

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一世旳自豪 2024-11-16 17:58:51

GlassFishRutime.newGlassFish(GlassFishProperties)GlassFishRuntime 的 javadoc .bootstrap(BootstrapProperties) 有点想要细节......

有一个asadmin 创建域参考页面。您可以设置的属性之一称为“orb.listener.port”...这可能有助于解决此问题。我还注意到,domain.xml 文件利用系统属性进行端口定义(打开domain.xml 文件并搜索“IIOP_LISTENER_PORT”)。我猜想这两个字符串之一将是 BootstrapProperties 或 GlassFishProperties 属性的关键,它将执行您想要的操作。

The javadoc for GlassFishRutime.newGlassFish(GlassFishProperties) and the javadoc for GlassFishRuntime.bootstrap(BootstrapProperties) are a bit wanting for detail...

There is a '--domainproperties' option described on the asadmin create-domain reference page. One of the properties that you can set is called 'orb.listener.port'... That may be useful in resolving this. I also noticed that the domain.xml file leverages system properties for port definitions (open the domain.xml file and search for 'IIOP_LISTENER_PORT'). I would guess that one of these two strings will be the key for a BootstrapProperties or GlassFishProperties property that will do what you want.

绾颜 2024-11-16 17:58:51

我得到了以下解决方案(以及一些有用的方法):

public synchronized CommandResult runCommand(String command, String... parameters)
throws GlassFishException {   
  CommandRunner runner = this.gfInstance.getCommandRunner();
  CommandResult result = runner.run(command, parameters);
  checkCommandResult(command, result);
  return result;
}
private void checkCommandResult(String cmd, CommandResult result) {
  LOG.info("Command: {}\n  Result.status:\n  {}\n  Result.out:\n  {}\n  Result.failCause:\n  {}\n", 
  new Object[] {cmd, result.getExitStatus(), result.getOutput(), result.getFailureCause()});
  if (result.getExitStatus().ordinal() != 0) {
    throw new IllegalStateException("Command '" + cmd + "' was unsuccessful: " 
    + result.getOutput(),
    result.getFailureCause());
}

然后我可以调用几乎任何内容,就像使用 asadmin 命令一样:
示例:

runCommand("list", "configs.config.server-config.iiop-service.iiop-listener");

在日志中生成:

  Result.status:
  SUCCESS
  Result.out:
  PlainTextActionReporterSUCCESSDescription: list AdminCommandnull
    configs.config.server-config.iiop-service.iiop-listener.SSL
    configs.config.server-config.iiop-service.iiop-listener.SSL_MUTUALAUTH
    configs.config.server-config.iiop-service.iiop-listener.orb-listener-1

  Result.failCause:
  null

然后再次查看domain.xml并设置您想要的任何内容:
http://embedded-glassfish.java.net/domain.xml
例如,在我的 EGF 初始化中,我在部署之前和实例启动之后调用此方法:

runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.orb-listener-1.port=" + 50000);
runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.SSL.port=" + 50001);
runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.SSL_MUTUALAUTH.port=" + 50002);

I got following solution (and some helpful methods):

public synchronized CommandResult runCommand(String command, String... parameters)
throws GlassFishException {   
  CommandRunner runner = this.gfInstance.getCommandRunner();
  CommandResult result = runner.run(command, parameters);
  checkCommandResult(command, result);
  return result;
}
private void checkCommandResult(String cmd, CommandResult result) {
  LOG.info("Command: {}\n  Result.status:\n  {}\n  Result.out:\n  {}\n  Result.failCause:\n  {}\n", 
  new Object[] {cmd, result.getExitStatus(), result.getOutput(), result.getFailureCause()});
  if (result.getExitStatus().ordinal() != 0) {
    throw new IllegalStateException("Command '" + cmd + "' was unsuccessful: " 
    + result.getOutput(),
    result.getFailureCause());
}

Then I can call nearly anything just like with asadmin command:
Example:

runCommand("list", "configs.config.server-config.iiop-service.iiop-listener");

produces in log:

  Result.status:
  SUCCESS
  Result.out:
  PlainTextActionReporterSUCCESSDescription: list AdminCommandnull
    configs.config.server-config.iiop-service.iiop-listener.SSL
    configs.config.server-config.iiop-service.iiop-listener.SSL_MUTUALAUTH
    configs.config.server-config.iiop-service.iiop-listener.orb-listener-1

  Result.failCause:
  null

And then you look into domain.xml again and set whatever you want:
http://embedded-glassfish.java.net/domain.xml
For example in my EGF initialization I call this before deploy and after instance startup:

runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.orb-listener-1.port=" + 50000);
runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.SSL.port=" + 50001);
runCommand("set", 
 "configs.config.server-config.iiop-service.iiop-listener.SSL_MUTUALAUTH.port=" + 50002);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文