2 Replies Latest reply on Oct 2, 2017 2:58 AM by Mike Figo

    Can not find EJB component - JNDI javax.naming.NameNotFoundException

    Mike Figo Newbie

      I'm trying to access my EJBs with their full names. The name is a String :

      private final String ejbJndiLocation = "java:global/" + app + ".ear/myApp-ejb.jar/MyEjbModule!com.ejb.service.impl.MyEjbModule"; 

      This is the exact name when I go through the installed applications on WAS. Though, when I access it with :

      context = new InitialContext(); MyEjbModule = (MyEjbLocal) context.lookup(ejbJndiLocation); 

      I get the following exception :

      javax.naming.NameNotFoundException: Context: MC41367Node01Cell/applications, name: myApp.ear/myApp.ear/myApp-ejb.jar/MyEjbModule!com.ejb.service.impl.MyEjbModule: First component in name myApp.ear/myApp.ear/myApp-ejb.jar/MyEjbModule!com.ejb.service.impl.MyEjbModule not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0] at com.ibm.ws.naming.jndicos.CNContextImpl.mapNotFoundException(CNContextImpl.java:4564) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1822) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1777) at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1434) ... Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0 at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.handleNameNotFound(WsnOptimizedNamingImpl.java:2534) at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.getNextWsnOptimizedNamingContext(WsnOptimizedNamingImpl.java:1277) at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase$3.run(WsnOptimizedNamingImplBase.java:4670) at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase$3.run(WsnOptimizedNamingImplBase.java:4665)

      Here are the bindings written in the console while starting up the application :





      Is there a way to find out the full name on the server? I really need to access it with the full name.

      Technologies: Java6, EJB 3.1

        • 1. Re: Can not find EJB component - JNDI javax.naming.NameNotFoundException
          Greg Jewell Apprentice

          It looks like your lookup name is incorrect.  Wildfly is telling you that it's deploying the EJB with name




          But you're looking for




          Your "app" variable looks like it's resolving to "myApp.ear/myApp".  Can you not modify your lookup to match what Wildfly is telling you the lookup name is?


          Alternatively, you can tell Wildfly what you want the lookup name to be by modifying the annotation on the class marking it as an EJB (eg. @Stateless(mappedName="...") ).

          • 2. Re: Can not find EJB component - JNDI javax.naming.NameNotFoundException
            Mike Figo Newbie

            Perfect. I was using the path as from file system from previous tests.


            It works now. Thank you for your reply !


            (By the way, there's a mistake in my initial post, when looking up for the ejb, the correct syntax is : MyEjbLocal myEjb = (MyEjbLocal) context.lookup(ejbJndiLocation);)