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

Reply via email to