14 Replies Latest reply on Jun 27, 2014 4:50 AM by jaikiran pai

    EJB invocations from a remote server instance

    Christoph Keimel Newbie

      Hello

       

      I am testing remote invocations from one server to another. I tried the configuration following this article:

      https://docs.jboss.org/author/display/WFLY8/EJB+invocations+from+a+remote+server+instance

       

      For test purposes I have two wildfly instances running localy. I deployed a simple test bean (RemoteTest) on the destination server (localhost:9080). The RemoteTest bean is deployed ok, since I can reach it from a client application. I am trying to call this bean from another bean (TestBean) on the client server (localhost:8080). I modified the standalone.xml of the client server:

       

      <security-realms>

        ...

        <security-realm name="remote-ejb-security-realm">

        <server-identities>

        <secret value="YWRtaW4x"/>

        </server-identities>

        </security-realm>

      </security-realms>

      ...

      <subsystem xmlns="urn:jboss:domain:remoting:2.0">

        <endpoint worker="default"/>

        <http-connector name="http-remoting-connector" connector-ref="default" security-realm="EJBRealm"/>

        <outbound-connections>

        <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb" protocol="http-remoting" security-realm="remote-ejb-security-realm" username="admin">

        <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">

        <remote-destination host="localhost" port="9080"/>

        </outbound-socket-binding>

      </socket-binding-group>

       

      When I try to establish the connection with this code

       

      props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");final Hashtable<String, String> props = new Hashtable<String, String>();

      final Context context = new InitialContext(props);

      RemoteTest service = (RemoteTest) context.lookup("ejb:GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote");

      logger.info(service.helloWorld());

       

      I receive this exception:

       

      Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:GosaEjb3TestRemoteEAR, moduleName:de.emsw.gosa.ejb3.test.remote.server, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@9dc933

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

        at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116) [jboss-ejb-client-2.0.0.Final.jar:2.0.0.Final]

      ...

       

      Thanks for any pointers of what I could try, to get this working.

       

      Regards

      Christoph

        • 1. Re: EJB invocations from a remote server instance
          jaikiran pai Master

          Christoph Keimel wrote:

          RemoteTest service = (RemoteTest) context.lookup("ejb:GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote");

          ...

          I receive this exception:

           

          Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:GosaEjb3TestRemoteEAR, moduleName:de.emsw.gosa.ejb3.test.remote.server, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@9dc933

          That JNDI name you are using looks wrong. Take a look at this post on what it's expected to be Re: Remote call of EJB in an EAR-File does not work in Wildfly

          • 2. Re: Re: EJB invocations from a remote server instance
            Christoph Keimel Newbie

            Hi Jaikiran

             

            thanks for the input. Unfortunaltely adding an empty "distinct name" didn't help:

             

            09:23:33,388 INFO  [de.emsw.gosa.ejb3.test.MiscTestBean] (EJB default - 2) Lookup Remote Bean: ejb:GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server//RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote

            09:23:33,390 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 2) JBAS014134: EJB Invocation failed on component MiscTestBean for method public abstract void de.emsw.gosa.ejb3.test.MiscTest.callRemoteEjb(): javax.ejb.EJBException: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:GosaEjb3TestRemoteEAR, moduleName:de.emsw.gosa.ejb3.test.remote.server, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@7279b2

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]

                ...

            Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:GosaEjb3TestRemoteEAR, moduleName:de.emsw.gosa.ejb3.test.remote.server, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@7279b2

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

                ...

             

            Or did I miss your point?

             

            BTW: I'm using Wildfly 8.0.0. Could it help to migrate to 8.1.0?

             

            Regards

            Christoph

            • 3. Re: EJB invocations from a remote server instance
              Tom Blank Newbie

              From what I see, you are packaging your app as EAR. I guess, you have some modules, where your remote calls are seperated in a module.Since Wildfly 8.9, the call has been changed. Try out this one:

               

              private static final String BUILD_FILE = "ejb:your-ear-file/your-module-1.0/";

               

              public static YourManagerInterface getYourManager() {

                      Context jndiContext;

                      try {

                          jndiContext = getInitialContext();

               

                          Object ref = jndiContext.lookup(BUILD_FILE+"YourManager!"+YourManagerInterface.class.getName());

                          return (YourManagerInterface) ref;

                      } catch (NamingException e) {

                          return null;

                      }

                  }

               

               

              - Don't forget the exclamation mark...

              - The Manager is located in "your-module-1.0"

              • 4. Re: EJB invocations from a remote server instance
                jaikiran pai Master

                When your application is deployed, the server prints out the JNDI names of the beans in the server.log and also on the console terminal. Please post those logs.

                • 5. Re: EJB invocations from a remote server instance
                  Christoph Keimel Newbie

                  These are the JNDI names logged during startup of the destination server:

                   

                  09:37:03,052 INFO  [org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016002: Processing weld deployment de.emsw.gosa.ejb3.test.remote.server.jar

                  09:37:03,055 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-9) JNDI bindings for session bean named RemoteTestBean in deployment unit subdeployment "de.emsw.gosa.ejb3.test.remote.server.jar" of deployment "GosaEjb3TestRemoteEAR.ear" are as follows:

                   

                    java:global/GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestLocal

                    java:app/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestLocal

                    java:module/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestLocal

                    java:global/GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote

                    java:app/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote

                    java:module/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote

                    java:jboss/exported/GosaEjb3TestRemoteEAR/de.emsw.gosa.ejb3.test.remote.server/RemoteTestBean!de.emsw.gosa.ejb3.test.remote.RemoteTestRemote

                   

                  I usualy use the last entry, copy everything after " java:jboss/exported/" and prefix it with "ejb:".

                  • 6. Re: EJB invocations from a remote server instance
                    Tom Blank Newbie

                    Then, from what I can see, you should do this:

                     

                    public static RemoteTestLocal getMyRemoteManager() {

                            Context jndiContext;

                            try {

                                jndiContext = new InitialContext();

                     

                                Object ref = jndiContext.lookup("ejb:/GosaEjb3TestRemoteEAR/RemoteTestBean!"+RemoteTestLocal.class.getName());

                                return (RemoteTestLocal) ref;

                            } catch (NamingException e) {

                                return null;

                            }

                        }

                    • 7. Re: EJB invocations from a remote server instance
                      Wolf-Dieter Fink Master

                      That seems correct to me so far, the jar module name looks a bit strange but I don't think that this is an issue.

                      Did that worked?

                      Maybe you use the quickstart ejb-multi-server from here : git@github.com:wildfly/quickstart.git

                      There is a configuration that worked and you can compare it.

                       

                      Do you have any errors or warnings in the logfile of the 'client' server?

                      You might configure org.jboss logging for TRACE to see more informations during the connect.

                      • 8. Re: EJB invocations from a remote server instance
                        Wolf-Dieter Fink Master

                        Tom,

                        that is wrong as it is deployed as a EAR file and you need to use ejb:<ear name>/<module name>/<BeanName>!<full qualified view name>

                        • 9. Re: EJB invocations from a remote server instance
                          Tom Blank Newbie

                          Hi Wolf-Dieter,

                           

                          I thought about the module, but according to his log, it does not seem to me, that his Bean is inside a module. That's why I came up with this proposal:

                          Object ref = jndiContext.lookup("ejb:/GosaEjb3TestRemoteEAR/RemoteTestBean!"+RemoteTestLocal.class.getName());

                           

                          If his Bean is stored in a module, then of course you are right and he should follow the convention you mentioned.

                          • 10. Re: EJB invocations from a remote server instance
                            Christoph Keimel Newbie

                            Hi Wolf-Dieter

                             

                            I'll have a look at the quickstart. Thanks for the info.

                            I don't think the JNDI name itself is the issue, since the lookup works on a "normal" client.

                             

                            Greetings

                            Christoph

                            • 11. Re: EJB invocations from a remote server instance
                              jaikiran pai Master

                              It looks like the client server hasn't established a connection with the destination server. Do you have a jboss-ejb-client.xml in your client application's deployment? What does it look like and where exactly is it placed.

                               

                              You might also want to enable TRACE level logs of org.jboss.ejb.client on the client server for more finer logs.

                              • 12. Re: Re: EJB invocations from a remote server instance
                                Christoph Keimel Newbie

                                Hi everyone

                                 

                                thanks a lot for all your input! I realy appreciate it!

                                 

                                @Wolf-Dieter: Looking at the quickstart I see that you are using a domain configuration for the servers. Is that mandatory? I'm asking, because in our case we have two standalone servers which we would like to connect.

                                 

                                @Jaikiran: Thanks for the tip about the logging (blushing ... I could have thought of that myself). You are correct: Since I don't see any output from org.jboss.ejb.client, I suspect that the ejb client is not used. Another sign for this is that, when I also deploy GosaEjb3TestRemoteEAR.ear on the client-server, the lookup will return the local bean.

                                 

                                Client Server Deployment

                                GosaEjb3TestEAR.ear

                                    - de.emsw.gosa.ejb3.test.server.jar

                                    - lib

                                          - de.emsw.gosa.ejb3.test.client.jar

                                          - de.emsw.gosa.ejb3.test.remote.client.jar

                                    - META-INF

                                          - application.xml

                                          - jboss-ejb-client.xml


                                Destination Server Deployment

                                GosaEjb3TestRemoteEAR.ear

                                     - de.emsw.gosa.ejb3.test.remote.server.jar

                                     - lib

                                          - de.emsw.gosa.ejb3.test.remote.client.jar

                                     - META-INF

                                          - application.xml


                                jboss-ejb-client.xml

                                <jboss-ejb-client>

                                    <client-context>

                                        <ejb-receivers>

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

                                        </ejb-receivers>

                                    </client-context>

                                </jboss-ejb-client>

                                • 13. Re: EJB invocations from a remote server instance
                                  Christoph Keimel Newbie

                                  Hello again

                                   

                                  I managed to resolve the issue. I went through all the steps again and used a console to start the servers as described in the article. Suddendly everything worked as expected. The problem was that I had started my servers using the Eclipse Server View. I was expecting that the "Host name" setting would be enough to set the "jboss.node.name" Property. This is not the case.

                                   

                                  In the end, this boils down to a case of RTFM. Sorry for wasting your time.

                                   

                                  Greetings

                                  Christoph

                                   

                                  Off-Topic: Wolf-Dieter Fink? : What kind of parachute are you flying on the picture? Looks a lot like the Stilleto I used to fly

                                  • 14. Re: EJB invocations from a remote server instance
                                    jaikiran pai Master

                                    Thank you for posting the cause of the problem.

                                     

                                    The solution you ended up using is the right thing to do (setting jboss.node.name system property to be unique per server instance if multiple server instances are on same machine)