2 Replies Latest reply on Oct 26, 2011 4:58 AM by mrshadow

    Get configurable remote EJB reference from another jboss6 instance

    mrshadow

      Hello,

       

      I have this dramatically simple problem I can't get solved...

       

      2 Jboss-6.0.0.Final instance on a network :

      - Instance one as Web tier (host1),

      - Instance two as Application Tier (host2).

       

      A war is deployed on the web tier (host1). This war contains an stateless EJB that try to get connectivity on a Remote EJB (deployed on host2). It works fine by doing this injection :

       

      @EJB(mappedName="jnp://host2:1099/ejb/jndiRemoteName")

      RemoteBean myRemoteBean;

       

      Now, I'm on deployment purpose, and trying to make this configurable with xml... and trying to get smthing like this :

       

      @EJB(mappedName="localJndiName")

      RemoteBean myRemoteBean;

       

      I tried to put the reference "jjnp://host2:1099/ejb/jndiRemoteName" everywhere, but unable to make it work... (everywhre = jboss.xml , web.xml, jboss-web.xml ... )

       

      Should I try another approach, like "connecting" the 2 jndi local registries ?

       

      Now I really need help please !

        • 1. Re: Get configurable remote EJB reference from another jboss6 instance
          jaikiran

          So you want to override the @EJB mappedName via a xml? You can do that via a ejb-ref element in the jboss.xml.

           

          Something like:

           

          @EJB(name="matchingNameInEJBRefInXml", mappedName="localJndiName")

          RemoteBean myRemoteBean;

           

          <ejb-ref>

            <ejb-ref-name>matchingNameInEJBRefInXml</ejb-ref-name>

            <jndi-name>TheJNPRemoteJNDIName</jndi-name>

            ....

          </ejb-ref>

          • 2. Re: Get configurable remote EJB reference from another jboss6 instance
            mrshadow

            Many thanks for your help !

            Since I already tried this, that's I was doing something wrong... So I double check according to your response, and it's working fine ( in jboss.xml, the <ejb-name> was mapped on the Interface... arg !)

             

            The 'problem' with this solution (override annotation with xml) is I have to write a jboss.xml conf for each local bean, even if I am injecting the same remote EJB

             

            Is there any way to get the remote ejb referenced in the local JNDI tree with some kind of XML conf ? So I could inject this local ref without having to override annotation

             

            In each local ejb (without having to write an '<session><ejb-ref>...' per local bean) :

            @EJB(mappedName="localJndiNameOfRemoteBean")

             

            And a JNDIView with something like this :

            + localJndiNameOfRemoteBean

                + jnp://host2:1099/...../RemoteBean

             

            (If this is not possible, i'll code my own local proxy to do this...)