SessionServiceBean
我在我的 Jboss As 7.1 服务器上部署了一个会话 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 查找所需的权限吗?我实际上不知道为什么这不起作用。那是我第一次使用远程 ejb。