我在Jboss As 7.1服务器上部署了一个名为SessionServiceBean
的会话bean。在部署时,我在控制台中获得以下输出,侦听该bean的正确JNDI标识符:
JNDI bindings for session bean named SessionServiceBean in deployment unit subdeployment "account-ejb.jar" of deployment "replay-ear.ear" are as follows:
java:global/replay-ear/account-ejb/SessionServiceBean!de.replay.account.SessionService
java:app/account-ejb/SessionServiceBean!de.replay.account.SessionService
java:module/SessionServiceBean!de.replay.account.SessionService
java:jboss/exported/replay-ear/account-ejb/SessionServiceBean!de.replay.account.SessionService
java:global/replay-ear/account-ejb/SessionServiceBean
java:app/account-ejb/SessionServiceBean
java:module/SessionServiceBean
现在,如果我尝试在JUnit测试用例中查找bean:
service = (SessionService) jndiCtx.lookup("java:global/replay-ear/account-ejb/SessionServiceBean!de.replay.account.SessionService");
我得到一个异常,告诉我服务器找不到bean:
javax.naming.NameNotFoundException: global/replay-ear/account-ejb/SessionServiceBean!de.replay.account.SessionService -- service jboss.naming.context.java.jboss.exported.global.replay-ear.account-ejb."SessionServiceBean!de.replay.account.SessionService"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我不明白这个错误,因为jndi标识符与日志中输出的标识符匹配,而我的客户端肯定是连接到正确的服务器。
可能是我用于身份验证的用户没有jndi查找所需的权限吗?我实际上不知道为什么这不起作用。这是我第一次使用远程ejbs。
答案 0 :(得分:0)
显然错误是将java:global
保留在JNDI标识符中。
工作查找现在看起来像这样:
service = (SessionService) jndiCtx.lookup("/replay-ear/account-ejb/SessionServiceBean!de.replay.account.SessionService");