EJB 3.0 local lookup fails with OC4J & JDK 1.5.x

Discussions

EJB programming & troubleshooting: EJB 3.0 local lookup fails with OC4J & JDK 1.5.x

  1. EJB 3.0 local lookup fails with OC4J & JDK 1.5.x (1 messages)

    Hi All, am trying to lookup the local ejb interface but it's throwing NameNotFoundException Sample code is here: 1) Local Interface @Local public interface CircuitServiceLocal { ... } 2) Remote Interface @Remote public interface CircuitService { ... } 3) EJB @Stateless public class CircuitServiceSlsb implements CircuitService, CircuitServiceLocal { ... } 4) Registring a reference to CircuitServiceSLSB EJB under the logical name CircuitServicesRef In the ReportingServiceSlsb EJB, I am trying to lookup the local ejb interface CircuitServiceLocal. @Stateless @EJB(name="CircuitServicesRef", beanInterface=CircuitServiceLocal.class, beanName="CircuitServiceSLSB") public class ReportingServiceSlsb implements ReportingService { ..... ..... public void createReport() { InitialContext context = new InitialContext(); CircuitServiceLocal circuitServiceLocal = (CircuitServiceLocal)context.lookup("java:comp/env/CircuitServicesRef"); } } Problem Description: Here in the createReport() method the lookup fails throwing the NameNotFoundException. (try catch is there in the code but not shown.) In createReport() method I want the reference of the CircuitService EJB (local). Exception: javax.naming.NameNotFoundException: java:comp/env/CircuitServicesRef not found in ReportingServiceSlsb Can anybody explain what is going wrong here. I am using OC4J 10.1.3.4.0 and JDK 1.5.0_16 I know here I can inject the local ejb using @EJB annotation, (and that works fine in my code) but for different reason, I have to use the JNDI lookup method. One more thing is that, I am using the lookup method to lookup the remote interface by passing the ejb name CircuitServiceSLSB, it is working fine. the remote Lookup CircuitService circuitService = (CircuitService) context.lookup("CircuitServiceSLSB"); Thanks & Regards, Mahesh
  2. I had a very similar issue and managed to resolve it by adding an orion-ejb-jar.xml file to my EJB project & configuring it as recommended in this blog post:

    http://www.xinotes.org/notes/note/592/

     

    Hope that helps!