Version 6

    Problem description

     

    components are accessing the ejb local homes assuming they know what the global jndi binding is. Since the upgrade to 3.2.7 / 4.0.2, this doesn't work anymore, because now the old JNDI name is appended by the "@" character and a random number. This also applies to MDBs.

     

     

    Diagnosis

     

    This is a side effect of the resolution to http://jira.jboss.com/jira/browse/JBAS-275#action_12315001 : To avoid clashes between two identically-named EJBs, a generated hash-code is now appended to the JNDI name to make them unique unless a local-jndi-name value is provided in the deployment descriptor

     

    Solution

     

    Put in a value for the attribute ejb-link in ejb-jar.xml/web.xml or a local-jndi-name in jboss.xml/jboss-web.xml and look up by that value.

     

    An mdb local-jndi-name example:

       <enterprise-beans>
          <message-driven>
             <ejb-name>TestMDB</ejb-name>
             <local-jndi-name>TestMDB</local-jndi-name>
             <mdb-user>...</mdb-user>
             <mdb-passwd>...</mdb-passwd>
          </message-driven>
       </enterprise-beans>
    

     

    An ejb-link example that does not need to know the jndi name:

    <ejb-jar>
       <description>a.jar Test ENC ejb-jar.xml descriptor</description>
       <enterprise-beans>
          <session>
             <description>Session Bean</description>
             <ejb-name>SessionA</ejb-name>
             <home>org.jboss.test.naming.interfaces.TestEjbLinkHome</home>
             <remote>org.jboss.test.naming.interfaces.TestEjbLink</remote>
             <local-home>org.jboss.test.naming.interfaces.TestEjbLinkLocalHome</local-home>
             <local>org.jboss.test.naming.interfaces.TestEjbLinkLocal</local>
             <ejb-class>org.jboss.test.naming.ejb.TestEjbLinkBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
    
          <session>
             <description>Session Bean</description>
             <ejb-name>SessionB</ejb-name>
             <home>org.jboss.test.naming.interfaces.TestEjbLinkHome</home>
             <remote>org.jboss.test.naming.interfaces.TestEjbLink</remote>
             <local-home>org.jboss.test.naming.interfaces.TestEjbLinkLocalHome</local-home>
             <local>org.jboss.test.naming.interfaces.TestEjbLinkLocal</local>
    
             <ejb-class>org.jboss.test.naming.ejb.TestEjbLinkBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
             <ejb-local-ref>
                <ejb-ref-name>ejb/LocalSessionA</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <local-home>org.jboss.test.naming.interfaces.TestEjbLinkLocalHome</local-home>
                <local>org.jboss.test.naming.interfaces.TestEjbLinkLocal</local>
                <ejb-link>SessionA</ejb-link>
             </ejb-local-ref>
         </session>
    ...
    

     

    References

     

     

    Small Print

    Because jboss has to guarentee that the generated jndi name it uses to bind the local home under is globally unique since there is no requirement that every ejb-name associated with a local home is unique. Its an implementation detail of jboss that the local homes are even stored in jndi. In 4.0.1sp1, a change was made to use a more robust default local home jndi name to avoid conflicits what showed up if two seperate ejb jars with the same ejb-name that only exposed local interfaces were deployed. Previously this required that a jboss.xml local-jndi-name be specified. Since this effectively was requiring the user to deal with a jboss implementation detail, we changed the default jndi name for local homes. The side-effect of this is that apps using lookups into the global jndi tree for local homes now have to specify the ejb-local-ref elements that should have been used all along, or use a local-jndi-name in the jboss.xml descriptor to provide a globally unique name for the local home binding. The use of the ejb-local-ref is the standard and portable solution.

     

    This also applies to MDBs because they happen to use a semantic similar to local ejb interfaces for their invoker. If you need to know the object name for an MDB container as in the case of dependencies, use the local-jndi-name in the jboss.xml descriptor.

     

    Referenced by: