我在查找我的 ejb 时遇到问题。在 servlet 中一切正常,但我需要从远程客户端连接到 ejb。
从部署控制台日志:
java:global/easymenu-webappEAR/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
java:app/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
java:module/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
java:jboss/exported/easymenu-webappEAR/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
java:global/easymenu-webappEAR/EasyMenu/CounterBean
java:app/EasyMenu/CounterBean
java:module/CounterBean
我在 webapp 中有 ejbmodule(我不知道它是如何分开的)
获取上下文:
public static InitialContext getInitialContext(String url) throws NamingException {
Properties properties = new Properties();
properties.setProperty(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
properties.setProperty(Context.PROVIDER_URL, url);
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.setProperty(Context.SECURITY_PRINCIPAL, "pch");
properties.setProperty(Context.SECURITY_CREDENTIALS, "peterch");
return new InitialContext(properties);
}
抬头:
CounterBeanRemote cbr = (CounterBeanRemote) ServiceLocator
.getInitialContext("remote://localhost:8080").lookup("java:app/EasyMenu/CounterBean!"
+ CounterBeanRemote.class.getName());
System.out.println("Result: " + cbr.getMessage());
例外
mar 20, 2013 10:27:04 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
mar 20, 2013 10:27:04 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
mar 20, 2013 10:27:04 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
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:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at sk.jbase.projects.easymenu.client.EasyMenuClient.getInitialContext(EasyMenuClient.java:58)
at sk.jbase.projects.easymenu.client.EasyMenuClient.main(EasyMenuClient.java:38)
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)
... 6 more