2 Replies Latest reply: Jan 28, 2011 4:12 PM by dvohra21 RSS

    javax.naming.NameNotFoundException

    761228
      When I develop ejb 3.0 project using JDeveloper 11g, it is ok. But, when I am trying to develop with Eclipse IDE and stand lone Weblogic Applicaiton Server 10.3.1, I got javax.namiing.NameNotFoundException. I tried to used different each of the weblogic client jar files likes weblogic thin client, remote client and full client java files. But I am still facing this exception.

      package com.java.servicerecord.ejb.interfaces;

      @Remote
      public interface IServiceRecordEAO {
      public ServiceRecord addNewServiceRecord(ServiceRecord resource);
      }

      package com.java.servicerecord.ejb;

      @Stateless(name = "ServiceRecordEAO", mappedName = "ServiceRecordEAO")
      public class ServiceRecordEAO implements IServiceRecordEAO {
      ...........
      }

      package com.java.servicerecord;

      public class ServiceRecordTest {
      private static Context getInitialContext() throws NamingException {
      Hashtable env = new Hashtable();
      // WebLogic Server 10.x connection details
      env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
      env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
      return new InitialContext(env);
      }

      public IServiceRecordEAO getServiceRecordEAO() {
      IServiceRecordEAO result = null;
      try {
      final Context context = getInitialContext();
      result = (IServiceRecordEAO)context.lookup("ServiceRecordEAO#com.java.servicerecord.ejb.interfaces.IServiceRecordEAO");
      } catch (Exception ex) {
      ex.printStackTrace();
      }
      return result;
      }

      }
      javax.naming.NameNotFoundException: While trying to lookup 'ServiceRecordEAO#com.java.servicerecord.ejb.interfaces.IServ
      iceRecordEAO' didn't find subcontext 'ServiceRecordEAO#com'. Resolved '' [Root exception is javax.naming.NameNotFoundExc
      eption: While trying to lookup 'ServiceRecordEAO#com.java.servicerecord.ejb.interfaces.IServiceRecordEAO' didn't find su
      bcontext 'ServiceRecordEAO#com'. Resolved '']; remaining name 'ServiceRecordEAO#com/java/servicerecord/ejb/interfaces/IS
      erviceRecordEAO'
           at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
           at weblogic.jndi.internal.ServerNamingNode_1031_WLStub.lookup(Unknown Source)
           at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:400)
           at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:388)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at com.java.servicerecord.ServiceRecordTest.getServiceRecordEAO(ServiceRecordTest.java:47)
           at com.java.servicerecord.ServiceRecordTest.initResources(ServiceRecordTest.java:55)
           at com.java.servicerecord.ServiceRecordTest.main(ServiceRecordTest.java:107)
      Caused by: javax.naming.NameNotFoundException: While trying to lookup 'ServiceRecordEAO#com.java.servicerecord.ejb.inter
      faces.IServiceRecordEAO' didn't find subcontext 'ServiceRecordEAO#com'. Resolved ''
           at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
           at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
           at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
           at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
           at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
           at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
           at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
           at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
           at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
           at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      javax.naming.NameNotFoundException: While trying to lookup 'ResourceEAO#com.java.resource.ejb.interfaces.IResourceEAO' d
      idn't find subcontext 'ResourceEAO#com'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying
      to lookup 'ResourceEAO#com.java.resource.ejb.interfaces.IResourceEAO' didn't find subcontext 'ResourceEAO#com'. Resolve
      d '']; remaining name 'ResourceEAO#com/java/resource/ejb/interfaces/IResourceEAO'
           at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
           at weblogic.jndi.internal.ServerNamingNode_1031_WLStub.lookup(Unknown Source)
           at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:400)
           at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:388)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at com.java.servicerecord.ServiceRecordTest.getResourceEAO(ServiceRecordTest.java:36)
           at com.java.servicerecord.ServiceRecordTest.initResources(ServiceRecordTest.java:56)
           at com.java.servicerecord.ServiceRecordTest.main(ServiceRecordTest.java:107)
      Caused by: javax.naming.NameNotFoundException: While trying to lookup 'ResourceEAO#com.java.resource.ejb.interfaces.IRes
      ourceEAO' didn't find subcontext 'ResourceEAO#com'. Resolved ''
           at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
           at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
           at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
           at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
           at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
           at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
           at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
           at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
           at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
           at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      Exception in thread "main" java.lang.NullPointerException
           at com.java.servicerecord.ServiceRecordTest.initResources(ServiceRecordTest.java:56)
           at com.java.servicerecord.ServiceRecordTest.main(ServiceRecordTest.java:107)

      Edited by: user10791554 on Jan 26, 2011 11:57 PM

      Edited by: user10791554 on Jan 27, 2011 11:45 PM
        • 1. Re: javax.naming.NameNotFoundException
          Jay SenSharma MiddlewareMagic
          Hi,

          Your code and the Lookup JNDI name looks fine...so not sure what is causing the issue.....but the following error suggests that it is not able to find the subcontext "com"
          Caused by: javax.naming.NameNotFoundException: While trying to lookup 'ResourceEAO#com.java.resource.ejb.interfaces.IRes
          ourceEAO' didn't find subcontext 'ResourceEAO#com
          So just for testing can you try customizing your EJB's JNDI name to some short customized name like described in the following link: http://middlewaremagic.com/weblogic/?p=120


          If customizing JNDI name is not an option for you then please do the following:

          1). Open the JNDI Tree in the Admin Console of the server where the EJB application is targeted...and then check if the JNDI name of EJBs are visible there?

          2). If you don't see the JNDI entry in the Tree then please redeploy your application and check the Server Log for any kind of WARNING message....many times the deployment is not complete ...it fails with few components but the Application state looks good.


          Thanks
          Jay SenSharma
          • 2. Re: javax.naming.NameNotFoundException
            dvohra21
            If a mapped name is used:
            InitialContext context = new InitialContext();
            ServiceRecordEAO beanRemote = (ServiceRecordEAO) context.lookup("ServiceRecordEAO#com.java.servicerecord.ejb.ServiceRecordEAO");