adequate
adequate
adequate
adequate
 

JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   Forums 
September 19, 2018, 03:25:53 AM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: Not able to initialize Mongo client in Task  (Read 456 times)

pradeepjaini

  • JPPF Padawan
  • *
  • Posts: 7
Not able to initialize Mongo client in Task
« on: March 14, 2017, 12:55:49 PM »

Hi,

I need to initialize a MongoClient in Task object. But, I'm getting an error as below. I'm able to create the MongoClient instance from the normal client code in main() method. But, from TASK class, it's not happening. Any pointers in resolving this issue?

Code: MongoClient mongoClient = new MongoClient(host_ip, 27018);

Exception:
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
   at org.jppf.client.concurrent.JPPFTaskFuture.get(JPPFTaskFuture.java:107)
   at org.jppf.client.concurrent.JPPFTaskFuture.get(JPPFTaskFuture.java:84)
   at com.spire.mna.poc.jppf.signals.ExecutorSvcTest.runjob(ExecutorSvcTest.java:87)
   at com.spire.mna.poc.jppf.signals.ExecutorSvcTest.main(ExecutorSvcTest.java:38)
Caused by: java.lang.ExceptionInInitializerError
   at com.mongodb.connection.InternalStreamConnectionFactory.<init>(InternalStreamConnectionFactory.java:41)
   at com.mongodb.connection.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:68)
   at com.mongodb.connection.BaseCluster.createServer(BaseCluster.java:360)
   at com.mongodb.connection.SingleServerCluster.<init>(SingleServerCluster.java:54)
   at com.mongodb.connection.DefaultClusterFactory.create(DefaultClusterFactory.java:114)
   at com.mongodb.Mongo.createCluster(Mongo.java:744)
   at com.mongodb.Mongo.createCluster(Mongo.java:728)
   at com.mongodb.Mongo.<init>(Mongo.java:293)
   at com.mongodb.Mongo.<init>(Mongo.java:288)
   at com.mongodb.Mongo.<init>(Mongo.java:284)
   at com.mongodb.MongoClient.<init>(MongoClient.java:179)
   at com.mongodb.MongoClient.<init>(MongoClient.java:156)
   at com.mongodb.MongoClient.<init>(MongoClient.java:146)
   at com.spire.mna.poc.jppf.signals.NewAdditionTask.call(NewAdditionTask.java:49)
   at com.spire.mna.poc.jppf.signals.NewAdditionTask.call(NewAdditionTask.java:1)
   at org.jppf.client.taskwrapper.CallableTaskWrapper.execute(CallableTaskWrapper.java:57)
   at org.jppf.client.taskwrapper.JPPFAnnotatedTask.run(JPPFAnnotatedTask.java:79)
   at org.jppf.execute.NodeTaskWrapper.run(NodeTaskWrapper.java:158)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Thanks,
Pradeep Jaini.
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2240
    • JPPF Web site
Re: Not able to initialize Mongo client in Task
« Reply #1 on: March 14, 2017, 02:21:10 PM »

Hello,

I was able to reproduce with the Mongo Java driver v3.4.2. The full stack trce is like this:

Code: [Select]
java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
  at org.jppf.client.concurrent.JPPFTaskFuture.get(JPPFTaskFuture.java:107)
  at org.jppf.client.concurrent.JPPFTaskFuture.get(JPPFTaskFuture.java:84)
  at test.mongo.TestMongo.main(TestMongo.java:38)
Caused by: java.lang.ExceptionInInitializerError
  at com.mongodb.connection.InternalStreamConnectionFactory.<init>(InternalStreamConnectionFactory.java:41)
  at com.mongodb.connection.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:68)
  at com.mongodb.connection.BaseCluster.createServer(BaseCluster.java:360)
  at com.mongodb.connection.SingleServerCluster.<init>(SingleServerCluster.java:54)
  at com.mongodb.connection.DefaultClusterFactory.create(DefaultClusterFactory.java:114)
  at com.mongodb.Mongo.createCluster(Mongo.java:744)
  at com.mongodb.Mongo.createCluster(Mongo.java:728)
  at com.mongodb.Mongo.<init>(Mongo.java:293)
  at com.mongodb.Mongo.<init>(Mongo.java:288)
  at com.mongodb.Mongo.<init>(Mongo.java:284)
  at com.mongodb.MongoClient.<init>(MongoClient.java:179)
  at com.mongodb.MongoClient.<init>(MongoClient.java:156)
  at com.mongodb.MongoClient.<init>(MongoClient.java:146)
  at test.mongo.TestMongo$MyTask.call(TestMongo.java:48)
  at test.mongo.TestMongo$MyTask.call(TestMongo.java:1)
  at org.jppf.client.taskwrapper.CallableTaskWrapper.execute(CallableTaskWrapper.java:57)
  at org.jppf.client.taskwrapper.JPPFAnnotatedTask.run(JPPFAnnotatedTask.java:79)
  at org.jppf.execute.NodeTaskWrapper.run(NodeTaskWrapper.java:158)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
  at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:113)
  at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:201)
  at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:182)
  at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:64)
  ... 25 more

It looks like we're hitting this MongoDB bug. They say it wil be fixed in 3.4.3/3.5.0, let's hope it will be very soon. Maybe in the meantime they provide daily snapshots that could keep you going?

Sincerely,
-Laurent
Logged

pradeepjaini

  • JPPF Padawan
  • *
  • Posts: 7
Re: Not able to initialize Mongo client in Task
« Reply #2 on: March 15, 2017, 05:14:54 AM »

Thanks for your quick reply Laurent. Your information was really helpful.

- Pradeep Jaini.
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads