title: JNDI lookup fails in a thread created by J2EE/JCR application on WAS 8.0.0.4 running on Red Hat Enterprise Server 5.8 (2.6.18-308.e15)
body: <p><strong>JNDI lookup fails in a thread created by J2EE/JCR application on WAS 8.0.0.4 running on Red Hat Enterprise Server 5.8(2.6.18-308.e15).</strong></p>
  
  <p><em>I am using Jackrabbit Repository (jcr's implementation) as backend in my Web Appl.Whose data persists on Oracle Database. To make connection with Oracle database jackrabbit provide JNDI Lookup to read the data source defined in WAS (using WAS 8.0.0.4 as App Server).
  I am able to perform JNDI Lookup everywhere in my application, But in a flow where i am creating a Thread using Java Concurrent Api and inside thread's call() method when I am trying for JNDI Look following exception occurs –</em></p>
  
  <p>[8/20/13 10:57:35:163 IST] 000000dd System Out     O ERROR 20-08 10:57:35,163 (DatabaseFileSystem.java:init:209)            failed to initialize file system
  javax.jcr.RepositoryException: JNDI name not found: java:comp/env/jdbc/ofsds
                  at org.apache.jackrabbit.core.util.db.ConnectionFactory.getJndiDataSource(ConnectionFactory.java:295)
                  at org.apache.jackrabbit.core.util.db.ConnectionFactory.createDataSource(ConnectionFactory.java:233)
                  at org.apache.jackrabbit.core.util.db.ConnectionFactory.getDataSource(ConnectionFactory.java:166)
                  at org.apache.jackrabbit.core.fs.db.DbFileSystem.getDataSource(DbFileSystem.java:226)
                  at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:190)
                  at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1057)
                  at org.apache.jackrabbit.core.config.RepositoryConfig.getFileSystem(RepositoryConfig.java:911)
                  at org.apache.jackrabbit.core.RepositoryImpl.(RepositoryImpl.java:285)
                  at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:605)
                  at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:232)
                  at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:280)
                  at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:376)
                  at com.mmpnc.icm.server.repository.RepositoryStartupService.newSession(RepositoryStartupService.java:408)
                  at com.mmpnc.icm.server.repository.RepositoryStartupService.newSession(RepositoryStartupService.java:355)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  at java.lang.reflect.Method.invoke(Method.java:611)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                  at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                  at com.mmpnc.icm.server.repository.RepositoryStartupService_$$_javassist_1.newSession(RepositoryStartupService_$$_javassist_1.java)
                  at com.mmpnc.icm.server.repository.ICMHouseKeepingSessionManager.create(ICMHouseKeepingSessionManager.java:37)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  at java.lang.reflect.Method.invoke(Method.java:611)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                  at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                  at com.mmpnc.icm.server.repository.ICMHouseKeepingSessionManager_$$_javassist_8.create(ICMHouseKeepingSessionManager_$$_javassist_8.java)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  at java.lang.reflect.Method.invoke(Method.java:611)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
                  at org.jboss.seam.Component.callComponentMethod(Component.java:2171)
                  at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
                  at org.jboss.seam.Component.newInstance(Component.java:2054)
                  at org.jboss.seam.Component.getInstance(Component.java:1948)
                  at org.jboss.seam.Component.getInstance(Component.java:1910)
                  at org.jboss.seam.Component.getInstance(Component.java:1904)
                  at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2271)
                  at org.jboss.seam.Component.getValueToInject(Component.java:2223)
                  at org.jboss.seam.Component.injectAttributes(Component.java:1663)
                  at org.jboss.seam.Component.inject(Component.java:1481)
                  at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                  at com.mmpnc.icm.server.repository.ICMHouseKeepingRepository_$$_javassist_7.create(ICMHouseKeepingRepository_$$_javassist_7.java)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  at java.lang.reflect.Method.invoke(Method.java:611)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
                  at org.jboss.seam.Component.callComponentMethod(Component.java:2171)
                  at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
                  at org.jboss.seam.Component.newInstance(Component.java:2054)
                  at org.jboss.seam.Component.getInstance(Component.java:1948)
                  at org.jboss.seam.Component.getInstance(Component.java:1910)
                  at org.jboss.seam.Component.getInstance(Component.java:1904)
                  at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2271)
                  at org.jboss.seam.Component.getValueToInject(Component.java:2223)
                  at org.jboss.seam.Component.injectAttributes(Component.java:1663)
                  at org.jboss.seam.Component.inject(Component.java:1481)
                  at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                  at com.mmpnc.icm.server.repository.ICMHouseKeepingManager_$$_javassist_6.create(ICMHouseKeepingManager_$$_javassist_6.java)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  at java.lang.reflect.Method.invoke(Method.java:611)
                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                  at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
                  at org.jboss.seam.Component.callComponentMethod(Component.java:2171)
                  at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
                  at org.jboss.seam.Component.newInstance(Component.java:2054)
                  at org.jboss.seam.Component.getInstance(Component.java:1948)
                  at org.jboss.seam.Component.getInstance(Component.java:1910)
                  at org.jboss.seam.Component.getInstance(Component.java:1904)
                  at org.jboss.seam.Component.getInstance(Component.java:1899)
                  at com.mmpnc.icm.server.concurrent.PerformCloseTask.call(PerformCloseTask.java:136)
                  at com.mmpnc.icm.server.concurrent.PerformCloseTask.call(PerformCloseTask.java:1)
                  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
                  at java.util.concurrent.FutureTask.run(FutureTask.java:149)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
                  at java.lang.Thread.run(Thread.java:770)
  Caused by:
  javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".]
                  at com.ibm.ws.naming.java.javaURLContextImpl.throwExceptionIfDefaultJavaNS(javaURLContextImpl.java:522)
                  at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:552)
                  at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:481)
                  at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
                  at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)
                  at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
                  at javax.naming.InitialContext.lookup(InitialContext.java:436)
                  at org.apache.jackrabbit.core.util.db.ConnectionFactory.getJndiDataSource(ConnectionFactory.java:280)
                  ... 114 more
  Caused by:
  javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
                  at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1969)
                  at com.ibm.ws.naming.ipbase.NameSpace.retrieveBinding(NameSpace.java:1376)
                  at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1219)
                  at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1141)
                  at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
                  at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)
                  ... 119 more</p>