如何解决如何将嵌入式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);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。