如何将嵌入式glassfish 3.1配置为对3700的JNDI使用备用端口

问题描述

| 我有一个测试,该测试成功使用嵌入式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
    

解决方法

GlassFishRutime.newGlassFish(GlassFishProperties)的Javadoc和GlassFishRuntime.bootstrap(BootstrapProperties)的Javadoc都需要详细信息... 在asadmin创建域参考页面上有一个\'-domainproperties \'选项。您可以设置的属性之一称为\'orb.listener.port \'...这可能对解决此问题很有用。我还注意到domain.xml文件利用系统属性来定义端口(打开domain.xml文件并搜索\'IIOP_LISTENER_PORT \')。我猜这两个字符串之一将成为BootstrapProperties或GlassFishProperties属性的键,它们可以完成您想要的操作。     ,我得到以下解决方案(和一些有用的方法):
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);
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...