使用Jboss AS 7.1.1 Final,我试图通过JNDI调用本地EJB(3.1)。
我的本地EJB是:
@Stateless(mappedName = "Services")
@LocalBean
public class Services implements ServicesLocal {
.....// scary stuffs here
}
我的界面服务是:
@Local
public interface ServicesLocal {
.... // Some powerfull stuffs here
}
我试图像这样调用上面的EJB:
private ServicesLocal getLocalEJB() throws NamingException {
log.info("\n\n\n\n\n\n\n\n ################## Getting the ServicesLocal");
InitialContext context = new InitialContext();
return (ServicesLocal) context.lookup("ejb:/global/docs/docs-ejb-0.1/Services!com.mycompany.docs.local.ServicesLocal");
}
这是我在上面调用此代码时遇到的错误:
############获取ServicesLocal15:36:10,437 INFO [org.jboss.ejb.client](http-localhost-127.0.0.1-8080-1)JBoss EJB Client版本1.0.5.Final 15:36:10456
错误[stderr](http-localhost-127.0.0.1-8080-1)java.lang.IllegalStateException:没有EJB接收器可用于处理调用上下文org的[appName:,modulename:global,distinctname:docs]组合。 jboss.ejb.client.EJBClientInvocationContext@396f6a24 15:36:10457 错误[stderr](http-localhost-127.0.0.1-8080-1)^ Iat org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
这是Jboss 7.1.1 Final引导时的JNDI日志。拥有我想要调用的EJB:
15:07:07,975 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor](MSC服务线程1-7)部署单元子部署中名为Services的会话bean的JNDI绑定" docs-ejb -0.1.jar"部署" docs.ear"如下:
java:global/docs/docs-ejb-0.1/Services!com.mycompany.docs.local.ServicesLocal
java:app/docs-ejb-0.1/Services!com.mycompany.docs.local.ServicesLocal
java:module/Services!com.mycompany.docs.local.ServicesLocal
java:global/docs/docs-ejb-0.1/Services!com.mycompany.docs.services.Services
java:app/docs-ejb-0.1/Services!com.mycompany.docs.services.Services
java:module/Services!com.mycompany.docs.services.Services
我认为我的context.lookup("ejb:/global/docs/docs-ejb-0.1/Services!com.mycompany.docs.local.ServicesLocal")
错了。我可以做些什么来修复它并使用JNDI调用我的本地EJB?
答案 0 :(得分:0)
您是否尝试过使用JBoss告诉您的内容?
context.lookup("java:global/docs/docs-ejb-0.1/Services!com.mycompany.docs.local.ServicesLocal")
您的EJB存储在java
命名空间中,而不是ejb
中。