0

我已经搜索了网络和旧问题,但没有解决我问题的答案。全新安装 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 EJBReceiverContext{clientContext=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 EJBReceiverContext{clientContext=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 EJBModuleIdentifier{appName='TestEJB', moduleName='TestEJB', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=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 EJBModuleIdentifier{appName='TestEJB', moduleName='TestWeb', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=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 StatelessEJBLocator{appName='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)
4

2 回答 2

0

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

于 2013-07-07T08:51:35.410 回答
0

我找到了解决方案,将这一行添加到我的客户端代码中:

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

没有可用于处理的 EJB 接收器

于 2020-01-15T06:47:30.590 回答