1 Reply Latest reply on May 27, 2010 11:31 AM by Wolfgang Knauf

    deploying two diff versions of same EJB in two diff EARs

    Arbi Sookazian Master

      We have EJB1 (version 1) in EAR1 and EJB1 (version 2) in EAR2 deployed in %JBOSS_HOME%/server/default/deploy directory.

       

      How can we configure to ensure that each app (EAR) accesses the correct version of EJB1 in this same instance of JBoss 4.2.x?  Is it possible to do this considering the global JNDI namespace?

        • 1. Re: deploying two diff versions of same EJB in two diff EARs
          Wolfgang Knauf Master

          Hi,

           

          I think this should be possible. In the following snippets, I assume that you use EJB3.

           

          Step 1:in your EJB jar, you can define the global JNDI names of your beans.

          Either use annotations ("org.jboss.ejb3.annotation.RemoteBinding") on the bean class, or use a "jboss.xml" file:

           

           

          {code:xml}

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss PUBLIC
              "-//JBoss//DTD JBOSS 5.0//EN"
              "http://www.jboss.org/j2ee/dtd/jboss_5_0.dtd">
          <jboss>
              <enterprise-beans>
                  <session>
                      <ejb-name>MyBean</ejb-name>
                      <jndi-name>MyRemoteName</jndi-name>
                      <local-jndi-name>MyLocalName</local-jndi-name>
                  </session>
              </enterprise-beans>
          </jboss>

          {code}

           

          Step 2: in your client project, use a "jboss-web.xml" (for web client) or "jboss-client.xml" (for app client) and the ENC to map a ejb reference to this global name. Here is a snippet for a "jboss-web.xml":

           

           

          {code:xml}

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss-web PUBLIC
              "-//JBoss//DTD Web Application 5.0//EN"
              "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
          <jboss-web>
              ...
              <ejb-ref>
                  <ejb-ref-name>ejb/MyRemoteEjbRef</ejb-ref-name>
                  <jndi-name>MyRemoteName</jndi-name>
              </ejb-ref>

              <ejb-local-ref>
                  <ejb-ref-name>ejb/MyLocalRef</ejb-ref-name>
                  <local-jndi-name>MyLocalName</local-jndi-name>
              </ejb-local-ref>
          </jboss-web>

          {code}

          Of course, you have to declare those Environment Naming Context (ENC) entries also in "web.xml" or "application-client.xml"

           

          Hope this helps

           

          Wolfgang

           

          Sorry for the broken XML, this forum sucks sometimes...