1 Reply Latest reply on Jan 9, 2014 6:16 AM by hibernator_11

    MappedName property to inject remote EJB from another server

    nicolyra

      Hello all,

       

      I am migrating applications from JBOSS AS5 to JBOSS EAP 6.2 and I would like to take advantage of the opportunity to improve EJB management.

       

      Currently, remote EJB calls are all managed with JNDI lookup and I would like to use injection.

      I have two servers and each of them contains an EAR.

      The EAR of serverA contains EJB which have to use EJB from serverB.

       

      For the moment, I can inject them by using the JNDI name :

       

      public class ServerAClass {

        @EJB(lookup:"ejb:/ServerBEar/ServerBJar/ServerBClass!com.foo.ServerBInterface")

        private ServerBInterface myB;

        ...

      }

       

      But I would not have to specify all the time the ear and jar name (which will be different in production environment).

       

      I tried to use domain-naming tag in standalone.xml :

       

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

        <bindings>

        <lookup name="java:global/test-serverB" lookup="ejb:/ServerBear/ServerBjar/ServerBClass!com.foo.ServerBInterface"/>

        </bindings>

        <remote-naming/>

      </subsystem>

       

      public class ServerAClass {

        @EJB(lookup:"java:global/test-serverB")

        private ServerBInterface myB;

        ...

      }

       

      That works but I have too many EJB and too many configurations to do this for all my EJBs.

       

      I would like to use the mappedName property but that doesn't work (or maybe I don't use it correctly).

      That's why I would like to know :

      - Can we use mappedName property to inject EJB from a different server?

      - If we can, how can we do this?

      - Otherwise, is it possible to use the domain-naming tag (or another one) in standalone.xml to make a kind of shortcut to access to the ear/jar?

      - I spend lot of time on this problem because, for me, using injection is better than doing JNDI lookup manual but, is there an real advantage to use injection for calling remote EJB?

       

      Thanks in advance for your answers.