Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2794

Spring MongoTemplate through exception while accessing through spring @async(multithreading) method

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.5.0
    • Environment:
      Windows 64 bit.

      Hi,

      Got this error while trying to aggregate through spring data mongoDB in a Spring async method.

      java.lang.IllegalStateException: state should be: open
      	at com.mongodb.assertions.Assertions.isTrue(Assertions.java:70)
      	at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:82)
      	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
      	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
      	at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
      	at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:90)
      	at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:85)
      	at com.mongodb.operation.CommandReadOperation.execute(CommandReadOperation.java:55)
      	at com.mongodb.Mongo.execute(Mongo.java:836)
      	at com.mongodb.Mongo$2.execute(Mongo.java:823)
      	at com.mongodb.DB.executeCommand(DB.java:729)
      	at com.mongodb.DB.command(DB.java:491)
      	at com.mongodb.DB.command(DB.java:507)
      	at com.mongodb.DB.command(DB.java:462)
      	at org.springframework.data.mongodb.core.MongoTemplate$3.doInDB(MongoTemplate.java:410)
      	at org.springframework.data.mongodb.core.MongoTemplate$3.doInDB(MongoTemplate.java:408)
      	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:466)
      	at org.springframework.data.mongodb.core.MongoTemplate.executeCommand(MongoTemplate.java:408)
      	at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1576)
      	at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1511)
      	at com.metlife.impactview.service.DBComputationImpl.getPOIStreamByReferenceId(DBComputationImpl.java:616)
      	at com.metlife.impactview.service.MultiLevelAsyncServiceImpl.createJobLevelGraphForAllStreams(MultiLevelAsyncServiceImpl.java:188)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      	at com.sun.proxy.$Proxy119.createJobLevelGraphForAllStreams(Unknown Source)
      	at com.metlife.impactview.service.TestService.tester(TestService.java:75)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
      	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.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)
      

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            darsan55 Swapnadarsan moharana
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: