我在 JBoss AS 7 上有 @Remote EJB,可以通过 name 获得java:global/RandomEjb/DefaultRemoteRandom!pl.lechglowiak.ejbTest.RemoteRandom
。
独立客户端是使用<jee:remote-slsb>
bean 的 Spring 应用程序。尝试使用该 bean 时,我得到java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:RandomEjb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@1a89031
.
这是 applicationContext.xml 的相关部分:
<jee:remote-slsb id="remoteRandom"
jndi-name="RandomEjb/DefaultRemoteRandom!pl.lechglowiak.ejbTest.RemoteRandom"
business-interface="pl.lechglowiak.ejbTest.RemoteRandom"
<jee:environment>
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true
java.naming.security.principal=testuser
java.naming.security.credentials=testpassword
</jee:environment>
</jee:remote-slsb>
<bean id="remoteClient" class="pl.lechglowiak.RemoteClient">
<property name="remote" ref="remoteRandom" />
</bean>
RemoteClient.java 公共类 RemoteClient {
private RemoteRandom random;
public void setRemote(RemoteRandom random){
this.random = random;
}
public Integer callRandom(){
try {
return random.getRandom(100);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
我的 jboss 客户端 jar:org.jboss.as jboss-as-ejb-client-bom 7.1.2.Final pom
pl.lechglowiak.ejbTest.RemoteRandom 可用于客户端应用程序类路径。jndi.properties 包含确切的属性,<jee:environment>
如<jee:remote-slsb>
.
这样的代码无一例外地运行:
Context ctx2 = new InitialContext();
RemoteRandom rr = (RemoteRandom) ctx2.lookup("RandomEjb/DefaultRemoteRandom!pl.lechglowiak.ejbTest.RemoteRandom");
System.out.println(rr.getRandom(10000));
但是这个:
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
RemoteClient client = ctx.getBean("remoteClient", RemoteClient.class);
System.out.println(client.callRandom());
以异常结束:java.lang.IllegalStateException: EJBCLIENT000025: 没有 EJB 接收器可用于处理调用上下文 org.jboss.ejb.client.EJBClientInvocationContext@1a89031 的 [appName:, moduleName:RandomEjb, distinctName:] 组合。
jboss.naming.client.ejb.context=true
已设置。你知道我在哪里设置错误<jee:remote-slsb>
吗?