2 Replies Latest reply on May 2, 2014 8:57 PM by Kevin Stone

    JBOSS AS 7.2 Remote EJB Lookup

    Kevin Stone Novice

      I followed the instructions at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

      but I cant get it to work.  Basically I have 2 jars, Test.jar and Test2.jar.  Test2.jar is deployed on a remote server that is running Jboss AS 7.2 and Test.jar and Test2.jar are deployed on the local server also running Jboss AS 7.2

      I have configured the two instances of jboss according to the instructions.  See below

      When the Client runs it looks up the ejb on the local server and not the remote server.


      To run the test an MDB invokes BeanClient.callRemoteBean.  I would expect it to lookup the remote bean and write a file into the /home/redhat/ directory on the remote server but instead it looks up the ejb on the local server and writes the file locally.  If I remove Test2.jar on the local server it fails with an error cant find the EJB.


      Anyone have any idea?


      Here is the code and jboss stuff:



      REMOTE Server (the one with the Remote Bean) running JBOSS 7.2

      Per the instructions I added a user.


      What type of user do you wish to add?
      a) Management User (mgmt-users.properties)
      b) Application User (application-users.properties)
      enter: b
      Enter the details of the new user to add.
      Realm (ApplicationRealm) :
      Username : user1234
      Password : SOMEPASSSWORD#
      Re-enter Password : SOMEPASSSWORD#
      What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]:
      About to add user 'remoteuser' for realm 'ApplicationRealm'
      Is this correct yes/no? yes
      Added user 'user1234' to file '/opt/jboss-as-7.2.0.Final/standalone/configuration/application-users.properties'
      Added user 'user1234' to file '/opt/jboss-as-7.2.0.Final/domain/configuration/application-users.properties'
      Added user 'user1234' with roles  to file '/opt/jboss-as-7.2.0.Final/standalone/configuration/application-roles.properties'
      Added user 'user1234' with roles  to file '/opt/jboss-as-7.2.0.Final/domain/configuration/application-roles.properties'
      Is this new user going to be used for one AS process to connect to another AS process?
      e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
      yes/no? yes
      To represent the user add the following to the server-identities definition <secret value="VmVyXXXxNG5kIt=" />

      Test2.jar is deployed to the REMOTE server and has:

      package xx.test2;
      import javax.ejb.Remote;

      public interface BeanRemote {
      public void beanTest(String inputString);


      package xx.test2;
      import java.io.IOException;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import javax.ejb.Stateless;
      import org.apache.log4j.Logger;
      import org.jboss.ejb3.annotation.Pool;

      public class Bean implements BeanRemote {
      private static final Logger log = Logger.getLogger(Bean.class);
      public void beanTest(String inputString) {
        Path target = Paths.get("/home/redhat/Test.txt");
        try {
         Path file = Files.createFile(target);
        catch (IOException ex) {


      jboss-deployment-structure.xml in META-INF of Test2.jar:

      <?xml version="1.0"?>
        <module name="javax.annotation.api"/>        <module name="javax.ejb.api"/>
        <module name="javax.api"/>          <module name="org.apache.commons.cli"/>
        <module name="org.apache.log4j"/>
        <module name="javax.inject.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.transaction.api"/>
        <module name="org.jboss.ws.native.jbossws-native-core"/>
        <module name="org.jboss.ejb3"/>
        <module name="org.jboss.as.remoting"/>


      CLIENT Server running JBOSS AS 7.2


      Per the instructions I added these to the standalone-full.xml config file.

      <security-realm name="ejb-security-realm">
          <secret value="VmVyXXXxNG5kIt="/>


      <subsystem xmlns="urn:jboss:domain:remoting:1.1">
        <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
            <remote-outbound-connection name="remote-ejb-connection" outbound-socket-
        binding-ref="remote-ejb" username="user1234"
                <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                <property name="SSL_ENABLED" value="false"/>


      <outbound-socket-binding name="remote-ejb">
        <remote-destination host="XX.XX.XX.XX" port="4447"/>


      Test.jar is deployed to the CLIENT server:

      package xx.test;

      import xx.test2.BeanRemote;
      import java.util.Properties;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import org.apache.log4j.Logger;

      public class BeanClient {
      private static final Logger log = Logger.getLogger(BeanClient.class);
      BeanRemote remoteBean;

      public void callRemoteBean (String inputString) {
        try {

         //Tried this without properties and it didnt work.
         //It worked for a local jar lookup it didnt work for remote jar
         //Context ctx = new InitialContext();

         // JAR TO REMOTE JAR
         Properties env = new Properties();
         env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
         env.put("jboss.naming.client.ejb.context", "true");
         Context ctx = new InitialContext(env);
         BeanRemote remoteBean = null;
         try {
          Object returnObj =
          remoteBean = (BeanRemote) returnObj;
          if (remoteBean == null) {
           log.error("remoteBean not found");
          else {
         catch (Exception ex) {
         finally {

        } catch (NamingException e) {


      jboss-deployment-structure.xml in META-INF of Test.jar:

      <?xml version="1.0"?>
         <module name="javax.annotation.api"/>
         <module name="javax.ejb.api"/>  
         <module name="javax.api"/>   
         <module name="org.apache.commons.cli"/>
         <module name="org.apache.log4j"/> 
         <module name="javax.inject.api"/>
         <module name="javax.persistence.api"/>
         <module name="javax.transaction.api"/>
         <module name="org.jboss.ws.native.jbossws-native-core"/>
         <module name="org.jboss.ejb3"/>
         <module name="org.jboss.as.remoting"/>
         <module name="deployment.Test2.jar"/>


      jboss-ejb-client.xml file in the META-INF folder of Test.jar

      <jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">




                  <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/>