Spring <jee:remote-slsb>和JBoss AS7 - 没有EJB接收器可供处理

Lec*_*iak 8 spring ejb jboss7.x

我在JBoss AS 7上有@Remote EJB,可以通过名字获得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>
Run Code Online (Sandbox Code Playgroud)

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

}

我的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));
Run Code Online (Sandbox Code Playgroud)

但是这个:

ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
RemoteClient client = ctx.getBean("remoteClient", RemoteClient.class);
System.out.println(client.callRandom());
Run Code Online (Sandbox Code Playgroud)

以异常结束:java.lang.IllegalStateException:EJBCLIENT000025:没有EJB接收器可用于处理调用上下文的[appName:,moduleName:RandomEjb,distinctName:]组合org.jboss.ejb.client.EJBClientInvocationContext@1a89031.

jboss.naming.client.ejb.context=true已设定.你知道我错在哪里<jee:remote-slsb>吗?

小智 1

我刚刚解决了一个非常相似的问题。您是否创建了“jboss-ejb-client.propeties”文件?

如果没有,请查看这些: https : //docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI(特别是“设置 EJB 客户端上下文属性”子-话题)

https://community.jboss.org/message/740827

https://community.jboss.org/thread/197989

您应该将该文件放置在客户端的类路径中。下面是一个简单的示例:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=localhost
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

remote.connection.default.username=login
remote.connection.default.password=password
Run Code Online (Sandbox Code Playgroud)

祝你好运!

PS:此配置中唯一特定于项目的值是“用户名”和“密码”。

PS2:以防万一您尚未将用户添加到 jboss 设置中,可以通过位于 jboss 文件夹中的“bin/add-user.[bat/sh]”脚本完成。