1
votes

Hi this is my scenario,

I am trying to migrate an app from JBoss5 to JBoss7.

I am using jboss-as-7.1.1.Final.

The error I am getting is:

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]

I have looked at several discussions with the same error message but I just cant figure out what I am doing wrong.

In the deployments directory I have only one myapp.war. I do not deploy a .ear file. I have a dependency (myapp-ejb.jar) deployed as a module.

I have followed the instructions from https://docs.jboss.org/author/display/AS71/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 in section "Migrate EAP 5 Deployed Applications That Make Remote Invocations to AS 7".

SERVER In the myapp-ejb.jar I have a bunch of JNDI names like:

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

The lookup is done from the client by invoking this static method which is defined in 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;
}

All remote interfaces are for stateless EJB like:

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

CLIENT From the myapp.war I make a remote invocation to the myapp-ejb.jar using the above static method getAccountRemote(). In the myapp.war/WEB-INF directory I have added a jndi.properties and a jboss-ejb-client.properties.

The jndi.properties contains only one value:

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

The jboss-ejb-client.properties contains:

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

I have removed the security realm on remoting from the standalone.xml:

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

I have added the JBOSS_HOME/bin/client/jboss-client.jar to the myapp.war/WEB-INF/lib.

The application deploys successfully without any errors but when I launch localhost:8080/ I get the No EJB receiver available for handling error.

Does anyone knows what I have missed? Any suggestions?

2

2 Answers

0
votes
"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.
0
votes

You don't actually require jboss-client.jar if you are using JBOSS as your App server. Please add the following property to your initialContext or jndi.propeties file everything would be fine.

jboss.naming.client.ejb.context=true

also please remove the property unless you are calling from a standalone client or server other than Jboss.

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

Try with these settings.