1

嗨,这是我的场景,

我正在尝试将应用程序从 JBoss5 迁移到 JBoss7。

我正在使用 jboss-as-7.1.1.Final。

我得到的错误是:

No EJB receiver available for handling [appName:,modulename:myapp-ejb,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@6b9bb4bb
     at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
     at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
     at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
     at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
     at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
     at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

我查看了几个带有相同错误消息的讨论,但我无法弄清楚我做错了什么。

在部署目录中,我只有一个 myapp.war。我不部署 .ear 文件。我有一个作为模块部署的依赖项(myapp-ejb.jar)。

我已按照“迁移 EAP”部分中https://docs.jboss.org/author/display/AS71/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7中的说明进行操作5 对 AS 7 进行远程调用的已部署应用程序"。

服务器在 myapp-ejb.jar 我有一堆 JNDI 名称,如:

public static final String ACCOUNT_REMOTE = "ejb:/myapp-ejb//AccountBean!com.company.myapp.ejb.account.AccountRemote";

查找是通过调用 myapp-ejb.jar 中定义的这个静态方法从客户端完成的:

public static AccountRemote getAccountRemote() throws NamingException {
  if (accountRemote == null){
        InitialContext ic = new InitialContext();
        Object ref = ic.lookup(JNDINames.ACCOUNT_REMOTE); 
        accountRemote = (AccountRemote) PortableRemoteObject.narrow(ref, AccountRemote.class); 
  }
  return accountRemote;
}

所有远程接口都用于无状态 EJB,例如:

@Stateless
@Remote(AccountRemote.class)
public class AccountBean implements AccountRemote {

客户端 从 myapp.war 我使用上述静态方法 getAccountRemote() 对 myapp-ejb.jar 进行远程调用。在 myapp.war/WEB-INF 目录中,我添加了一个 jndi.properties 和一个 jboss-ejb-client.properties。

jndi.properties 只包含一个值:

java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

jboss-ejb-client.properties 包含:

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

我已从standalone.xml 中删除了远程处理的安全领域:

<subsystem xmlns="urn:jboss:domain:remoting:1.1">
          <connector name="remoting-connector" socket-binding="remoting" />
</subsystem>

我已将 JBOSS_HOME/bin/client/jboss-client.jar 添加到 myapp.war/WEB-INF/lib。

应用程序成功部署,没有任何错误,但是当我启动 localhost:8080/ 时,我得到 No EJB 接收器可用于处理错误。

有谁知道我错过了什么?有什么建议么?

4

2 回答 2

0

如果您使用 JBOSS 作为您的应用服务器,您实际上并不需要jboss-client.jar 。请将以下属性添加到您的 initialContext 或 jndi.propeties 文件中,一切都会好起来的。

jboss.naming.client.ejb.context=true

除非您从独立客户端或 Jboss 以外的服务器调用,否则请删除该属性。

java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

尝试使用这些设置。

于 2014-04-24T12:22:37.497 回答
0
"EJB client API approach" for remote EJB invocation from one node to another node in clustered JBOSS:
------------------------------------------------------------------------------------
1. To call EJB from remote location we need to enable "remoting-ejb-receiver" on server side.
    Please refer to “standalone_changes.xml” to know change details.
2. Also we need to register the "remoting-ejb-receiver" to the application, so that the application can receive remote EJB.
    Please refer to “jboss-ejb-client.xml” section.
3. Now we need to call remote EJB in "EJB client API approach" way, which needs to have JNDI name pattern as:
  ejb:<app-name>/<module-name>/<distinct-name>/<bean-name>!<fullclassname-of-the-remote-interface>
  In our case it will be: ejb:myapp-ejb//node1/AccountBean!com.company.myapp.ejb.account.AccountRemote
  Important to note that identification to remote location IP address is not based on InitialContext as InitialContext will not contain any IP address as normally happens with "remote://URL:Port".
  The remote location identification is based on <distinct-name> passed in JNDI. JBOSS will internally identify the remote IP based on <distinct-name>.
  Hence is required to provide unique <distinct-name> to the application running on different nodes.
  Add "<distinct-name>${jboss.node.name}</distinct-name>" to “jboss-app.xml”. Make sure that jboss.node.name property is always unique.
  But then jboss.node.name should be added as environmental property while server startup.
  For test purpose we can provide hardcoded value like: 
        For node1: "<distinct-name>node1</distinct-name>" to “jboss-app.xml”.
        For node2: "<distinct-name>node2</distinct-name>" to “jboss-app.xml”.


standalone_changes.xml:
------------------------------------------------------------------------------------
   <subsystem xmlns="urn:jboss:domain:remoting:1.1">
        <outbound-connections>
            <remote-outbound-connection name="remote-ejb-connection-host2" outbound-socket-binding-ref="remote-ejb-host2" username="xxx" security-realm="ejb-security-realm">
                <properties>
                    <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                    <property name="SSL_ENABLED" value="false"/>
                </properties>
            </remote-outbound-connection>
            ...........
            ...........
        </outbound-connections>
    </subsystem>
    ...........
    ...........
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">   
        <outbound-socket-binding name="remote-ejb-host2">
            <remote-destination host="${jboss.ejb.host2}" port="${jboss.ejb.host2.port}"/>
        </outbound-socket-binding>
        ...........
        ...........
    </socket-binding-group>
    ...........
    ...........
    <management>
        <security-realms>
            <security-realm name="ejb-security-realm">
                <server-identities>
                    <secret value="${jboss.ejb.remoting.password}"/>
                </server-identities>
            </security-realm>
            ...........
            ...........         
        </security-realms>
    </management>

jboss-app.xml:
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<jboss-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee">
    <distinct-name>node1</distinct-name>
    <security-domain>xyz</security-domain>
    <unauthenticated-principal>guest</unauthenticated-principal>
    <library-directory>lib</library-directory>
</jboss-app>

jboss-ejb-client.xml
------------------------------------------------------------------------------------
<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">
    <client-context>
        <ejb-receivers>
            <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection-host2"/>
            <!-- <remoting-ejb-receiver outbound-connection-ref="${jboss.remote.outbound.connection.host3}"/> -->
        </ejb-receivers>
    </client-context>
</jboss-ejb-client>


For more details refer to:
"https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project" which tells us different way of remote EJB location.
于 2014-04-21T11:43:16.897 回答