调用 EJB 的 JNDI JBoss 错误 - 没有可用于处理的 EJB 接收器

Posted

技术标签:

【中文标题】调用 EJB 的 JNDI JBoss 错误 - 没有可用于处理的 EJB 接收器【英文标题】:JNDI JBoss error calling EJB - No EJB receiver available for handling 【发布时间】:2013-02-28 07:55:33 【问题描述】:

我已经搜索了网络和旧问题,但没有解决我问题的答案。 全新安装 JBoss 7 1.1 final,我正在尝试使用 JNDI 调用 EJB。看起来连接正常,但实际调用方法时出错。

这里是 Java JNDI 代码:

InitialContext context = null;
Hashtable env = new Hashtable();
String ejbUrl = TestEJBClient.calculateJbossEjbJndiName ( "TestEJB" , "" , "" , TestEJB.class.getSimpleName ( ) , TestEJBRemote.class.getName ( ) , false );
env.put("jboss.naming.client.ejb.context", true);
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming" );
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "remote://localhost:4447");
env.put(Context.SECURITY_PRINCIPAL, "jboss");
env.put(Context.SECURITY_CREDENTIALS, "jboss1");
context = new InitialContext(env);
TestEJBRemote ejbRemote = (TestEJBRemote) context.lookup(ejbUrl);
Customer rtn = ejbRemote.getCustomerByAccountNumber(accountNumber);

这里是计算名字的方法:

public static String calculateJbossEjbJndiName(String appName , String moduleName , String distinctName , String beanName , String viewClassName, boolean stateful)

     String rtn = "ejb:"+appName+"/"+moduleName+"/"+distinctName+"/"+beanName+"!"+viewClassName;
     if (stateful)
     
          rtn = rtn + "?stateful";
     
     return rtn;

这是运行的日志:

[DEBUG][org.jboss.naming.remote.client.InitialContextFactory][getOptionMapFromProperties][12:20:25:PM][jboss.naming.client.connect.options. has the following options ]
[DEBUG][org.jboss.ejb.client.EJBClientPropertiesLoader][loadEJBClientProperties][12:20:26:PM][Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@35ce36]
[DEBUG][org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector][<init>][12:20:26:PM][EJB client context org.jboss.ejb.client.EJBClientContext@1543c88 will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers]
[DEBUG][org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver][handleDone][12:20:26:PM][Channel Channel ID 84a7a320 (outbound) of Remoting connection 00704baa to localhost/127.0.0.1:4447 opened for context EJBReceiverContextclientContext=org.jboss.ejb.client.EJBClientContext@1592174, receiver=Remoting connection EJB receiver [connection=Remoting connection <1ccce3c>,channel=jboss.ejb,nodename=ny-go-oss2790a] Waiting for version handshake message from server]
[INFO][org.jboss.ejb.client.remoting.VersionReceiver][handleMessage][12:20:26:PM][Received server version 1 and marshalling strategies [river]]
[INFO][org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver][associate][12:20:26:PM][Successful version handshake completed for receiver context EJBReceiverContextclientContext=org.jboss.ejb.client.EJBClientContext@1592174, receiver=Remoting connection EJB receiver [connection=Remoting connection <1ccce3c>,channel=jboss.ejb,nodename=ny-go-oss2790a] on channel Channel ID 84a7a320 (outbound) of Remoting connection 00704baa to localhost/127.0.0.1:4447]
[DEBUG][org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver][modulesAvailable][12:20:26:PM][Received module availability report for 2 modules]
[DEBUG][org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver][modulesAvailable][12:20:26:PM][Registering module EJBModuleIdentifierappName='TestEJB', moduleName='TestEJB', distinctName='' availability for receiver context EJBReceiverContextclientContext=org.jboss.ejb.client.EJBClientContext@1592174, receiver=Remoting connection EJB receiver [connection=Remoting connection <1ccce3c>,channel=jboss.ejb,nodename=ny-go-oss2790a]]
[DEBUG][org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver][modulesAvailable][12:20:26:PM][Registering module EJBModuleIdentifierappName='TestEJB', moduleName='TestWeb', distinctName='' availability for receiver context EJBReceiverContextclientContext=org.jboss.ejb.client.EJBClientContext@1592174, receiver=Remoting connection EJB receiver [connection=Remoting connection <1ccce3c>,channel=jboss.ejb,nodename=ny-go-oss2790a]]
[WARN][org.jboss.ejb.client.remoting.ChannelAssociation][handleMessage][12:20:26:PM][Unsupported message received with header 0xffffffff]
ejbUrl = ejb:TestEJB///TestEJB!org.test.services.om.TestEJBRemote
[INFO][org.jboss.ejb.client][<clinit>][12:20:26:PM][JBoss EJB Client version 1.0.5.Final]
ejbRemote = Proxy for remote EJB StatelessEJBLocatorappName='TestEJB', moduleName='', distinctName='', beanName='TestEJB', view='interface org.test.services.om.TestEJBRemote'
java.lang.IllegalStateException: No EJB receiver available for handling [appName:TestEJB,modulename:,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@105d88a
Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:TestEJB,modulename:,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@105d88a
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

【问题讨论】:

我想我是通过在 ejb 文件名之后添加 jar 文件名来完成这项工作的,必须先解决调用期间的错误,然后才能验证 检查这个:***.com/questions/11975396/… 【参考方案1】:

可能是因为客户端使用了 jar 文件。看一下这个 : https://community.jboss.org/thread/227862

【讨论】:

【参考方案2】:

我找到了解决办法,就是在我的客户端代码中加入这一行:

jndiProperties.put("jboss.naming.client.ejb.context", "true");

No EJB receiver available for handling

【讨论】:

以上是关于调用 EJB 的 JNDI JBoss 错误 - 没有可用于处理的 EJB 接收器的主要内容,如果未能解决你的问题,请参考以下文章

我无法设置我的 jndi.properties 来访问 Jboss 5 上的远程 EJB

远程客户端访问部署在 JBOSS AS 中的 EJB 的 JNDI 循环(7.1.1 最终版)

Jboss7.1 MDB - 本地 JNDI 参考与全球 JNDI 参考

解决EJB本地调用“java.lang.ClassCastException: $Proxy96 cannot be cast to com.tgb.ejb.UserManager”异常

在 JBoss 5.1 中以编程方式确定 JNDI 根上下文/耳朵名称

使用arquillian测试远程客户端jndi查找