0 Replies Latest reply: Sep 9, 2012 5:18 AM by PT Expert RSS

    JNDI lookup from OC4J to weblogic throws javax.naming.NameNotFoundException

    PT Expert
      Hi All,

      We have the below setup in our production environment.

      EJB application is deployed in the Weblogic 10.3.4.0 Server on Sun Solaris. The EJB version is 3.0

      OC4J 10.2.0 is running on another Sun Solaris machine.
      There are 2 webservice applications WEBSERV1 & TestSoapEJB running on this OC4J container.

      We need to do lookup the EJBs deployed on the Weblogic server. For this we used the below logic in the web service's Stateless session bean:

      String weblogicURL = "";

      Properties props = new Properties();
      try
      {
      props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("wl.properties"));
      weblogicURL     = props.getProperty("weblogicURL");     
      }
      catch (FileNotFoundException e)
      {
      e.printStackTrace();
      }
      catch (IOException e)
      {
      e.printStackTrace();
      }

      Context ctx = null;
      Hashtable ht = new Hashtable();
      ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      ht.put(Context.SECURITY_PRINCIPAL,"weblogic");
      ht.put(Context.SECURITY_CREDENTIALS,"weblogic654");
      ht.put(Context.PROVIDER_URL, weblogicURL);
      ctx = NamingManager.getInitialContext(ht) ;

      // tried using //ctx = new InitialContext(ht); same behavior.

      TestEJB.AdministratorEJB ejb = (TestEJB.AdministratorEJB) ctx.lookup("TestEJB#TestEJB.AdministratorEJB");

      ctx.close();


      When we first test first WEBSER1, the lookup is fine.
      But when we test the second webservice WEBSER2, the webservice name itself not able to lookup: It gives the below error:
      javax.naming.NameNotFoundException: remaining name: env/TestSoapEJB

      Below is the stack throws thrown on browser:
      500 Internal Server Error
      javax.naming.NameNotFoundException: remaining name: env/TestSoapEJB     
      at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)     
      at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)     
      at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:59)     
      at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:59)     
      at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:64)     
      at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)     
      at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)     
      at javax.naming.InitialContext.lookup(InitialContext.java:392)     
      at oracle.j2ee.ws.SessionBeanRpcWebService.init(SessionBeanRpcWebService.java:65)     
      at javax.servlet.GenericServlet.init(GenericServlet.java:258)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.loadServlet(HttpApplication.java:2354)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.findServlet(HttpApplication.java:4795)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2821)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:680)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)     
      at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)     
      at java.lang.Thread.run(Thread.java:662)


      It seems that, the OC4J is looking in Weblogic context. But it should be looking in its own context. How to resolve this issue.

      The same case happens if i restart the OC4J and first test the TestSoapEJB the lookup is fine . But if i test the WEBSERV1 , it throws the same error as above. In short, if one of the webservices lookup is working fine, the other webservice is not working. At the same time only one webservice's lookup is working.

      Kindly help me to resolve this issue.

      regards,
      Zia

      Edited by: PT Expert on Sep 9, 2012 3:16 AM