我有一个应用程序记录到另一台机器上的 JBoss 7.1 服务器上的 JMS 主题(应用程序代码 -> slf4j -> JDK 日志记录 -> JMS 主题)。日志记录适用于 JBoss 6,但不适用于 JBoss 7.1。相反,我在使用 JNDI 查找 JMS 主题时遇到以下异常:
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at ...<JMS/JNDI util classes>...
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at java.util.logging.LogManager$7.run(LogManager.java:919)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.initializeGlobalHandlers(LogManager.java:911)
at java.util.logging.LogManager.access$900(LogManager.java:129)
at java.util.logging.LogManager$RootLogger.getHandlers(LogManager.java:1018)
at java.util.logging.Logger.log(Logger.java:454)
at org.slf4j.impl.JDK14LoggerAdapter.log(JDK14LoggerAdapter.java:588)
at org.slf4j.impl.JDK14LoggerAdapter.info(JDK14LoggerAdapter.java:285)
at my.application.main(Unknown Source)
Caused by: java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)
at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 26 more
在应用程序的其他地方,我成功地使用相同的类和 JNDI 属性来查找 JMS 主题。此外,netcat 能够连接到 JBoss 服务器上的远程命名端口 (4447)。
知道为什么这不起作用吗?
编辑:这是我创建 InitialContext 的代码
final Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://192.168.xxx.xxx:4447");
props.put("java.naming.security.principal", "remote");
props.put("java.naming.security.credentials", "remotepwd");
InitialContext initialContext = new InitialContext(props);
编辑:启动脚本调用:
bin/standalone.sh -Djboss.bind.address=192.168.xxx.xxx -Djboss.bind.address.management=192.168.xxx.xxx -Djboss.bind.address.unsecure=192.168.xxx.xxx --server-config =standalone-full.xml -b=192.168.xxx.xxx -bmanagement=192.168.xxx.xxx