title: WebLogic 12c: Failed to initialize JNDI context
body: <p>WebLogic 12c JMS is behaving inconsistently in our system. We are using foreign JNDI provider to connect at remote JMS server as follows</p>
  
  <p><a href="https://i.stack.imgur.com/0geQr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0geQr.png" alt="enter image description here"></a></p>
  
  <p>Sometimes the JMS message sending fails with the following error</p>
  
  <pre><code>[Login failed for an unknown reason:  P] [Root exception is weblogic.socket.UnrecoverableConnectException: [Login failed for an unknown reason:  P]]
      at com.oracle.webservices.impl.jms.wls.transport.JmsTransportTube.process(JmsTransportTube.java:313)
      at com.oracle.webservices.impl.jms.wls.transport.JmsTransportTube.processRequest(JmsTransportTube.java:107)
      at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:139)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
      at com.sun.xml.ws.client.Stub.process(Stub.java:463)
      at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
      at com.sun.proxy.$Proxy280.*****(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:147)
      at com.sun.proxy.$Proxy266.*****(Unknown Source)
      at *****.utils.SynchronizingProxy.*****(SynchronizingProxy.java:155)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)
      at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:101)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)
      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
      at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
      at sun.reflect.GeneratedMethodAccessor707.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:94)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      at com.sun.proxy.$Proxy199.*****(Unknown Source)
      at *****.utils.SynchronizingProxy_3vv7m_NoIntfViewImpl.__WL_invoke(Unknown Source)
      at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:33)
      at *****.SynchronizingProxy_3vv7m_NoIntfViewImpl.*****(Unknown Source)
      at *****.*****(*****.java:469)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)
      at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:101)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)
      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73)
      at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
      at sun.reflect.GeneratedMethodAccessor707.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:94)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      at com.sun.proxy.$Proxy258.*****(Unknown Source)
      at *****.__WL_invoke(Unknown Source)
      at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:33)
      at *****.*****(Unknown Source)
      at *****.*****(*****.java:116)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:120)
      at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:93)
      at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149)
      at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
      at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:419)
      at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:868)
      at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:422)
      at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:169)
      at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:246)
      at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:667)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:368)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:163)
      at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:108)
      at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:286)
      at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:295)
      at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:128)
      at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:103)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:247)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3697)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3667)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
      at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
      at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2443)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2291)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2269)
      at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1705)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1665)
      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
      at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
      at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
      at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
      at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
      at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:652)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)
  Caused by: javax.naming.CommunicationException: Failed to initialize JNDI context, tried 2 time or times totally, the interval of each time is 0ms. 
  [Login failed for an unknown reason:  P] [Root exception is weblogic.socket.UnrecoverableConnectException: [Login failed for an unknown reason:  P]]
      at weblogic.jndi.WLInitialContextFactoryDelegate.throwRetryException(WLInitialContextFactoryDelegate.java:467)
      at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:403)
      at weblogic.jndi.Environment.getContext(Environment.java:353)
      at weblogic.jndi.Environment.getContext(Environment.java:322)
      at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:131)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
      at javax.naming.InitialContext.init(InitialContext.java:244)
      at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:216)
      at weblogic.jndi.internal.ForeignOpaqueReference.getReferent(ForeignOpaqueReference.java:70)
      at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:106)
      at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:1037)
      at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:1009)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:223)
      at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:527)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228)
      at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:527)
      at weblogic.jndi.internal.RootNamingNode.lookup(RootNamingNode.java:84)
      at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:307)
      at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:435)
      at com.oracle.webservices.impl.jms.wls.transport.JmsTransportTube.process(JmsTransportTube.java:143)
      ... 123 more
  Caused by: weblogic.socket.UnrecoverableConnectException: [Login failed for an unknown reason:  P]
      at weblogic.socket.Login.checkLoginSuccess(Login.java:131)
      at weblogic.rjvm.t3.MuxableSocketT3.connectSocket(MuxableSocketT3.java:734)
      at weblogic.rjvm.t3.MuxableSocketT3S.createMuxableSocket(MuxableSocketT3S.java:86)
      at weblogic.rjvm.t3.ConnectionFactoryT3S.createConnection(ConnectionFactoryT3S.java:45)
      at weblogic.rjvm.ConnectionManager.createConnection(ConnectionManager.java:2124)
      at weblogic.rjvm.ConnectionManager.findOrCreateConnection(ConnectionManager.java:1557)
      at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:505)
      at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:358)
      at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:318)
      at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:161)
      at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:258)
      at weblogic.rjvm.RJVMFinder.findOrCreateRemoteCluster(RJVMFinder.java:329)
      at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:227)
      at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170)
      at weblogic.rjvm.ClientServerURL.findOrCreateRJVM(ClientServerURL.java:177)
      at weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextFactoryDelegate.java:354)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:368)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:163)
      at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:350)
      ... 142 more
  </code></pre>
  
  <p>The error seems to occur randomly and persists for a while. What may cause this error? Does foreign JNDI keep alive a persistent TCP connection? Could it be a firewall which drops the inactive connection?</p>