4 Replies Latest reply on May 28, 2013 2:14 PM by cirou Branched to a new discussion.

    Remote EJB lookup from application within JBoss

    cirou

      Hi guys,

       

      at work we started using JBoss EAP 6.0.0 (Jboss AS 7.1.2 Final) but i'm pretty new to this and now i'm having some troubles to invoke a remote EJB from my application deployed on my JBoss EAP server.

       

      I'll try to be as clear as possible explaining my troubles.

      Thanks in advance to who will be so patient to read it all

       

       

       

      As first step to figure out how to make it work i created a little standalone app in my eclipse workspace.

      After some little troubles I've created a simple project containing the following files "RemoteEJBClient.java", a "jndi.properties" and a "jboss-ejb-client.properties" i've included a jboss-client.jar

      In the java class i make a lookup to a remote ejb starting with the "ejb:" prefix

      Without getting too much into the details: it works. I can lookup the ejb and i can also invoke its methods.

       

      Then i tried to apply what i learned in my application.

      First of all i have to explain you that:

      - My application is composed by an ear calling some common methods in my app's custom module.

      - The class in the module already lookup for remote ejbs deployed on the same server.

      - Now i'm trying to lookup for the remote ejb from the same class, but this ejb is deployed on another server.

       

      Ok, that's the troubles i had:

       

      First Try:

      same "jndi.properties" and a "jboss-ejb-client.properties" used for the little test client deployed in the module dir:

      Result:

      the lookup for the ejbs deployed on my server didn't work anymore cause it points to the remote server

       

      Second Try:

      only "jboss-ejb-client.properties" in the module dir, and the properties contained in the jndi file applied in my class java code

      Result:

      properties are loaded well, context is initialized and pointing to my remote server, but when i try to lookup the ejb (the one with the "ejb:" prefix) i get a NameNotFoundException but... the lookup string is the same working in my test app

       

      I don't know why the second try isn't working.

      All the properties seems correct (if i close my vpn client i get a connection error on the context initialization, too)

      Actually, I don't even know if this is the right way to do this.

       

      Please, if you can give me some tips to let it work...

      Thanks again

        • 1. Re: Remote EJB lookup from application within JBoss
          cfang

          For the same-server lookup, did you try using the portable global jndi name, in the form of java:global/...?  During deploy, you should see a list of portable global jndi names for a specific EJB.

          • 2. Re: Remote EJB lookup from application within JBoss
            sfcoy

            For this case:

            Ciro Aiello wrote:

            ...

            - Now i'm trying to lookup for the remote ejb from the same class, but this ejb is deployed on another server.

            ...

             

            have you looked at AS72 EJB invocations from a remote server instance?

            • 3. Re: Remote EJB lookup from application within JBoss
              cirou

              Cheng Fang ha scritto:

               

              For the same-server lookup, did you try using the portable global jndi name, in the form of java:global/...?  During deploy, you should see a list of portable global jndi names for a specific EJB.

               

              Yes Cheng, that's what i'm doing and the same-server lookup is perfectly working

               

               

               


              Stephen Coy ha scritto:

               

              For this case:

              Ciro Aiello wrote:

              ...

              - Now i'm trying to lookup for the remote ejb from the same class, but this ejb is deployed on another server.

              ...

               

              have you looked at AS72 EJB invocations from a remote server instance?

               

               

              Thanks, I'm reading it now, that's how i have to configure the two servers to make it work?

               

              Ok, i've read it and i'll try soon but i have a doubt... where i have to place the "jboss-ejb-client.xml" if i need it in my module and not in my application's ear?

               

               

              Update 1:

              I've configured the servers as descripted.

              The last problem I have is about the "jboss-ejb-client.xml".

              I put it in the jar of the module containing the ejb-client class but I'm getting a "java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling" I think it's not correctly loaded because if i delete the xml file i get the same error.

               

               

              Update 2:

              I tried to create a simple web project with a servlet working as ejb-client, i put the "jboss-ejb-client.xml" in the WEB-INF, deployed the .war on the server previously configured and the servlet successfully invoked the remote ejb

               

               

              Now... Ideas on where to put the "jboss-ejb-client.xml" on my main project to make it work?

               

               

              Thanks again

              • 4. Re: Remote EJB lookup from application within JBoss
                cirou

                Hi all again,

                 

                according to this topic: https://community.jboss.org/thread/228116  I deployed my ejb client class in a new application ear and now the "jboss-ejb-client.xml" is correctly loaded and the remote lookup works

                 

                Thank you again