3 Replies Latest reply on Jun 17, 2010 11:12 AM by wolfgangknauf

    Communication between EJBs across 2 ears

      Hi

      I have a "Role" bean implemented and deployed in Jboss as "svc" ear.

      I have a "Dbi" bean implemented and deployedin Jboss as "Dbi" ear.

       

      Now I want to call methods in the Role bean from Dbi bean methods.

      To do that I inject Role bean in Dbi using the code below...

       

      @EJB(name="Role", beanInterface=Role.class)

      roleLookup = (Role) new InitialContext().lookup("java:comp/env/ejb/Role");

       

      I keep getting "NameNotFoundException: Role not bound", when I run this code.

       

      How do I resolve this error? Is it possible at all?

      I am new to J2EE and to these forums. So I apologise if my message is in an incorrect format or improper forum.

      Thanks

      Sai

        • 1. Re: Communication between EJBs across 2 ears
          wolfgangknauf

          Hi,

           

          don't combine "@EJB" annotation and manual lookup, use only one way ;-).

           

          If you want to do the lookup yourself:

          How did you declare the environment naming context (ENC)? You need a JBoss specific file to do so. If you want to access the ENC from another session bean, you probably have to add a "jboss.xml" file to your project. In "ejb-jar.xml", you need an "ejb-ref" element, and "jboss.xml" also needs this element and points to the global JNDI name of the bean.

           

          Lookup will also work if you use the global JNDI name of your bean. This defaults to "earname/MyBean/local" for the local interface and "earname/MyBean/remote" for the Remote interface. In your sample, it should be "svc/Role/remote".

           

          Did you verify that the Role bean is bound to the JNDI names you expect (use the "JNDIView" mbean to check those bindings)?

           

          Hope this helps

           

          Wolfgang

          1 of 1 people found this helpful
          • 2. Re: Communication between EJBs across 2 ears

            Thanks for the helpful reply.

             

            Here is more information:

            RoleBean is the class that implements Role

             

            ejb-jar.xml of both the calling ear and the ear being called have only <display-name> tag. I do not have jboss.xml.

             

            The contents of the Global JNDI namesapce regarding my beans are...

             

            +- svc (class: org.jnp.interfaces.NamingContext)
              |   +- UnitBean (class: org.jnp.interfaces.NamingContext)
              |   |   +- local (proxy: $Proxy108 implements No ClassLoaders found for: ejb.Unit (no security manager: RMI class loader disabled))
              |   |   +- remote (proxy: $Proxy107 implements No ClassLoaders found for: ejb.Unit (no security manager: RMI class loader disabled))
              |   +- RoleBean (class: org.jnp.interfaces.NamingContext)
              |   |   +- local (proxy: $Proxy104 implements No ClassLoaders found for: ejb.Role (no security manager: RMI class loader disabled))
              |   |   +- remote (proxy: $Proxy103 implements No ClassLoaders found for: ejb.Role (no security manager: RMI class loader disabled))

             

            Both the statements below fail with the name not bound exception(whether I use @EJB or not):

             

            RoleBean roleLookup = (ejb.RoleBean) new InitialContext().lookup("svc/RoleBean/remote");

            or

             

            Role roleLookup = (ejb.Role) new InitialContext().lookup("svc/Role/remote");

             

            Any ideas how to fix this?

            Thanks

            • 3. Re: Communication between EJBs across 2 ears
              wolfgangknauf

              Hi,

               

              this part of the JNDIView results is strange:

               

              "remote (proxy: $Proxy103 implements No ClassLoaders found for:  ejb.Role (no security manager: RMI class loader disabled))"

               

              I have never seen this "No Class Loaders found" error before. Did you modify the JBoss config? Anything special about your app? Does it include JAR files or classes from JBoss core?

               

              Best regards

               

              Wolfgang