3 Replies Latest reply on Jul 28, 2016 12:26 PM by Erhard Siegl

    How to call an EJB in one EAR from another EAR in the same server?


      Dear Community,


      I have two EAR application deployed in the same JBoss AS EAP 6.

      On the first EAR (myapp1.ear) I have an EJB module (myejb.jar) with one Staless EJB (MyBusinessFacade) that implements a remote facade ("MyBusinessFacadeRemote").

      On the second EAR (myapp2.ear) I have an WAR module (mywebapp.war) with a JSF managed bean (MyControl).


      I want "MyControl" calls methods on "MyBusinessFacade" through "MyBusinessFacadeRemote".

      The only way I could get it working (ie. locate the EJB correctly) was using the "lookup" attribute of the @EJB annotation and passing the global JNDI name of "MyBusinessFacadeRemote". The code on "MyControl" looks like:


      public class MyControl {

          @EJB(lookup = "java:global/myapp1/myejb/MyBusinessFacade!com.mycompany.business.MyBusinessFacadeRemote")

          private MyBusinessFacadeRemote facade;



      It is working fine, but the lookup string is fixed in the code.


      Here is my question:

      Is there any way I could call that EJB without putting that string fixed in my code?

      Ideally I wanted it could be just annotated with @EJB, and no parameters. :-)