8 Replies Latest reply on Apr 24, 2014 10:54 AM by stonesoft

    JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules

    trupti.r

      Hi,

       

      Currently I have three JBoss AS 7.1.1 standalone instances. One of them is EJB client  (Say Host 172.17.17.7) and other are publishing different EJB modules (Say Host 172.17.17.8 and 172.17.17.9).

      Currently I am trying to do JNDI lookup as follow:

      ejb-jar.xml

      <ejb-jar id="ejb-jar_ID" version="2.1"  

               xmlns="http://java.sun.com/xml/ns/j2ee

               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> 

       

          <enterprise-beans>

              <session>

                   <ejb-name>MyEjb</ejb-name>                       

                  <home>MyEjbRemoteHome</home>

                  <remote>MyEjbRemote</remote>

                  <ejb-class>MyEjbImpl</ejb-class>

                  <session-type>Stateless</session-type>

                  <transaction-type>Container</transaction-type>

              </session>

      </ejb>

       

      jboss.xml

      <jboss>

          <enterprise-beans>

              <session>

                  <ejb-name>MyEjb</ejb-name>

                  <jndi-name>java:/MyEjb</jndi-name>

              </session>

      <jboss>

       

       

      JBOSS Server output excerpt after deploying EJB is

       

      JNDI bindings for session bean named MyEjb in deployment unit subdeployment "myejjb-ejb.jar" of deployment "MyEjb.ear" are as follows:

           java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome

          java:module/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome

          java:jboss/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome

       

       

      I do look up of these EJB from code in JBoss AS server on 172.17.17.8 as follow:

       

                Properties env = new Properties();

              env.put(Context.INITIAL_CONTEXT_FACTORY,JbossSettings.getInitialConextetFactory());

              url = "remote://172.17.17.7:4447";

              env.put(Context.PROVIDER_URL,url);

              env.put(Context.SECURITY_PRINCIPAL,JbossSettings.getEusSecurityPrincipal());

              env.put(Context.SECURITY_CREDENTIALS, JbossSettings.getEusSecurityCredentials());

              InitialContext ctx = new InitialContext(env);

            ctx.lookup("java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome");

       

       

       

      But I am getting  javax.naming.NameNotFoundException: exception.


      Even I tried to add the

      <subsystem xmlns="urn:jboss:domain:naming:1.1">

                  <bindings>

                      <lookup name="UnLockServer" lookup="java:global/MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome"/>

        </bindings>

              </subsystem>

       

      But of no help.

       

      On the server hosting EJB I am getting logs as

      JBAS011806: Channel end notification received, closing channel Channel ID 52e62c8e (inbound) of Remoting connection 53fe497b

       

           

       

      Can some one help me what I am doing wrong?

       

      Is there any tutorial or example available where I can invoke different EJB's on different JBoss AS 7 from different JBOSS AS 7


        • 1. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
          wdfink

          There are several things:

          • On the server side you need to have an JNDI entry with "*/exported/your name" to be able to get the entry remote.
          • the jboss.xml is not longer supported, it will be ignored
          • if you use the remote:// protocol the lookup string is "MyEjb/myejb-ejb/MyEjb!com.test.MyEjbHome"


          THe message "JBAS011806" is a correct message as the client has closed the connection.

          1 of 1 people found this helpful
          • 2. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
            trupti.r

            Thanks for Reply Wolf-Dieter. You hit the bulls eye with JNDI name string. Look up is successful now. But I am getting following error after executing method on returned proxy.

             

            No EJB receiver available for handling [appName:MyEjb,modulename:myejb-ejb,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@5a8433bb

                at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

             

            I am executing the code on proxy as follow:

             

                        MyEjbHome test = (MyEjbHome)proxy;

                        MyEjb test1 = MyEjbHome.create();

                        String val  = test1.Hello();

             

            Is it possible to create alias to the ejb jndi on server and create context using that alias.

            • 3. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
              wdfink

              Successful lookup mean not that the server respond.

              In AS7 the lookup create a local instance of the interface as proxy but did not ask the server whether the bean is available, that happen if you invoke it.

               

              So you need to look whether the deployment and JNDI binding is correct.

              You might have a look to Remote EJB invocations via JNDI - EJB client API or remote-naming project

              • 4. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
                trupti.r

                Can I use this from code deployed in another application server Instance?

                • 5. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
                  trupti.r

                  Hi Wolf-Dieter

                   

                  Earlier I was mixing the EjbClientApi and remote naming approaches together. Now I sorted out things and using only remote naming approach. I created one simple project with Greeter ejb and its interface. This projected after deploying to JBoss Instance I was able to invoke ejb from another instance successfully. Jndi lookup and everything worked correctly. But when I incorporated the Greeter ejb in my project and tried to access I got exception saying

                                    EXCEPTION1:java.lang.IllegalStateException: No EJB receiver available for handling

                  Is this the generic exception or particularly occurs when binding is not correct.

                   

                  According to your earlier reply I should check whether the deployment and JNDI binding is correct. I tried all the various combinations with app name, modulename, distinct name etc.

                  Is there any other way by which I can validate whether my JNDI bindings are correct or not?

                  • 6. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
                    wdfink

                    I did not get exactly what you are doing.

                     

                    The problem is that the "No EJB receiver" message is generic and might have a lot of reasons

                    If you have a working example you might compare the JNDI log messages whether you see the same.

                    Also you might show your code and log.

                    • 7. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
                      trupti.r

                      Here is my deployment structure

                       

                      JBoss Instace 1 (192.17.17.1) (EJB-SERVER)

                      standalone

                           -- deployments

                                  -- AppA.ear

                                         -- MyEjb.jar

                                                  - com/test/Test and TestInterface (Ejb and interface)

                                         -- lib

                                        -- services.sar

                                        -- sswebapp.war

                                        -- META-INF

                                                 -- jboss-deployment-structure

                       

                       

                      JBossInstace 2 (192.17.17.2) (EJB-CLIENT)

                      standalon

                          -- deployments

                                  -- AppB.ear

                                        -MyAppBEjb.jar

                                        -- lib

                                              my.jar (which contains com/test/TestInterface)

                                        -- services.sar

                                             -- MBean (it invokes lookup on TestInterface)

                                 

                                        -- sswebapp1.war

                                        -- sswebapp2.war

                                        -- META-INF

                                             -- jboss-deployment-structure

                       

                       

                       

                      When I deploy app on EJB SERVER following is output

                      .

                      .

                      .

                      18:44:46,126 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "AppA.ear"

                      18:44:46,162 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "MyEjb.jar"

                      18:44:46,259 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-12) JNDI bindings for session bean named Service1 in deployment unit subdeployment "MyEjb.jar" of deployment "AppA.ear" are as follows:

                      ==============WORKING

                           java:global/AppA/MyEjb!com.test.TestInterface

                          java:app/AppA/MyEjb!com.test.TestInterface

                          java:module/MyEjb!com.test.TestInterface

                          java:jboss/exported/AppA/MyEjb!com.test.TestInterface

                       

                       

                       

                       

                      Now on client site I am doing this

                       

                                  Properties env = new Properties();

                                  env.put(Context.INITIAL_CONTEXT_FACTORY,JbossSettings.getInitialConextetFactory());

                                  env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                                  env.put(Context.PROVIDER_URL,"remote://192.17.17.1:4447");

                                  env.put(Context.SECURITY_PRINCIPAL,"test");

                                  env.put(Context.SECURITY_CREDENTIALS, "test123");

                       

                                 try{

                                     TestInterface  objref1 =  (TestInterface)ctx.lookup("AppA/MyEjb!com.test.TestInterface");

                                      System.out.println("!!!--------INVOKE1:"+objref1.sayHello());

                                  }catch (Exception e){}

                       

                       

                      I get exception like

                      java.lang.IllegalStateException: No EJB receiver available for handling

                       

                       

                      My Server side jboss-deployment-structure has following dependencies:

                                   <module name="org.jboss.remote-naming" export="true"/>

                                    <module name="org.jboss.marshalling" export="true"/

                                  

                       

                       

                       

                      I also tried by adding jboss-ejb-client.properties file. For that I removed above dependencies and added jboss-client.jar and dependency for

                                  <module name="org.jboss.xnio" export="true"/>

                                  <module name="org.jboss.xnio.nio" export="true"/>

                      And then created context like

                                  Properties props = new Properties();

                                  props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                                  props.put("jboss.naming.client.ejb.context", true);

                                  InitialContext ctx = new InitialContext(props);

                       

                       

                      But in this case also I got exception that javax.naming.NameNotFoundException:

                       

                       

                      Also I am running server using standalone.xml. Do I have to user standalone-full.xml?

                      • 8. Re: JBoss 7.1.1 EJB Lookup using JNDI from one server to multiple server with different EJB modules
                        stonesoft


                        I know its been a long time but did you ever get this to work?  I am having the same issue (I get noEJB receiver available).  It seems to me that it is looking on the local server and not the remote server.

                         

                        -kevin