11 Replies Latest reply on Jan 16, 2015 5:18 AM by Aditi Patil

    Using ejb-ref to mantain old JNDI bindings in code

    Mylos Kathos Master

      Hi all!

      I'm porting an application to JBoss AS 7. I have an issue with EJB: my EJBs, written for JBoss 4, and use a JNDI binding which is not accepted by JBoss AS 7:

       

      final Context context = new InitialContext(jndiProperties);

      return (TelcoInfo) context.lookup("ejb/TelcoInfo");

       

      Now I have added the new naming prefix to all EJB lookups:

       

      final Hashtable jndiProperties = new Hashtable();

      jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

       

      final Context context = new InitialContext(jndiProperties);

      return (TelcoInfo) context.lookup("ejb/TelcoInfo");

       

      I'd like to keep for the moment the old JNDI binding so I've added a jboss-ejb3.xml file containing the correct reference:

       

         <session>

             <session-type>Stateless</session-type>

               <ejb-name>TelcoInfo</ejb-name>

                <ejb-class>com.telco.ejb.TelcoInfoBean</ejb-class>

               

                <ejb-ref>

                  <ejb-ref-name>ejb/TelcoInfo</ejb-ref-name>

                  <lookup-name>ejb:/telecom//TelcoInfoBean!com.telco.ejb.TelcoInfo</lookup-name>

               </ejb-ref>

             

            </session>

       

      Unfortunately it does not work. I get as result:

      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

       

      (If I change manually the lookup in the code to ejb:/telecom//TelcoInfoBean!com.telco.ejb.TelcoInfo it works)

      Is the jboss-ejb3.xml still able to alias the old JNDI binding to the new one ?

      Thanks a lot

      Mylos