On 17/03/18 04:10, Priyam Srivastava wrote: > Hi Mark, > > Many Thanks for your response. I was able to resolve this issue by writing > the below code just before JNDI Look Up: > > Thread l_thread = Thread.currentThread(); > l_thread.setContextClassLoader(this.getClass().getClassLoader()); > initialContext = new InitialContext(); > .... > > > I have a questions based on the discussions on the thread link you provided: > > If this is something to do with ForkJoin Pool, then why it is happening > only in Tomcat why not in other application servers as I mentioned in my > initial post.
Because of the way Tomcat implements the memory leak protection for the problem described in bug 60620. I can't speak for the other containers as I don't know how their internals are coded. Mark > > Regards, > Priyam > > On Sat, Mar 17, 2018 at 2:22 AM, Mark Thomas <ma...@apache.org> wrote: > >> On 16/03/18 12:06, Priyam Srivastava wrote: >>> I have a scenario where we have to run some random number of independent >>> tasks to load data from DB. So I am using Java's fork Join framework to >>> create those task and then invoke them. >> >> See: >> https://bz.apache.org/bugzilla/show_bug.cgi?id=60620 and the various >> threads linked from there. >> >> Mark >> >> >>> >>> Each task opens its own connection using datasource and closes it. >>> >>> But in Tomcat, I am getting below error at line: >>> >>> initialContext = new InitialContext(); >>> >>> javax.naming.NoInitialContextException: Cannot instantiate class: >>> org.apache.naming.java.javaURLContextFactory >>> at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) >>> ~[?:1.8.0_161] >>> at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) >>> ~[?:1.8.0_161] >>> at javax.naming.InitialContext.init(Unknown Source) ~[?:1.8.0_161] >>> at javax.naming.InitialContext.<init>(Unknown Source) ~[?:1.8.0_161] >>> at com.dummy.test.TestClass.compute(TestClass.java:71) [classes/:?] >>> at java.util.concurrent.RecursiveAction.exec(Unknown Source) >> [?:1.8.0_161] >>> at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) >> [?:1.8.0_161] >>> at java.util.concurrent.ForkJoinPool$WorkQueue.execLocalTasks(Unknown >>> Source) [?:1.8.0_161] >>> at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) >>> [?:1.8.0_161] >>> at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) >> [?:1.8.0_161] >>> at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) >>> [?:1.8.0_161] >>> Caused by: java.lang.ClassNotFoundException: >>> org.apache.naming.java.javaURLContextFactory >>> >>> This error seems to be coming only in Tomcat and when I run the same code >>> in Wildfly/Glassfish or JBOSS EAP, everything works fine. >>> >>> On the other hand if I change my code and run these tasks using Thread >>> instead of Fork Join framework, I don't face this issue in Tomcat. >>> >>> So why this error is coming in Tomcat only? >>> >>> Note: I am getting this error after deploying in Tomcat and hitting app >> URL >>> from Postman. The so called missing class is already there in >>> jar catalina.jar present inside <Tomcat_Home>/lib >>> >>> Environment Details: >>> >>> Java Version: 1.8 >>> Tomcat Version: 8.5, 9.0.6 >>> OS: Windows 10 Pro 64 bit >>> Database: Oracle 11g and MySQL 5.7 >>> >>> I have uploaded a dummy code to simulate this issue in Git. Please refer >> to >>> the readme.txt for full details there. >>> >>> Git URL: >>> https://github.com/wambling/my-project.git >>> >>> Regards, >>> Priyam >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org