java.lang.IllegalStateException: Attempted to decrement the reference count below 0

JIRA | Jeff Yemin | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    We are using the mongoDB async java driver version 3.0.1. When doing performance tests (only reads) with a lot of concurrent requests to the driver, we sometimes encounter the following exception: {code} java.lang.IllegalStateException: Attempted to decrement the reference count below 0 at com.mongodb.binding.AbstractReferenceCounted.release(AbstractReferenceCounted.java:39) at com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.release(AsyncClusterBinding.java:113) at com.mongodb.operation.AsyncQueryBatchCursor.killCursor(AsyncQueryBatchCursor.java:154) at com.mongodb.operation.AsyncQueryBatchCursor.close(AsyncQueryBatchCursor.java:79) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:93) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:141) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:130) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:90) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:51) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:45) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.async.client.MongoClientImpl$2$1.onResult(MongoClientImpl.java:129) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.operation.OperationHelper$ConnectionReleasingWrappedCallback.onResult(OperationHelper.java:140) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:433) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:427) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:171) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.QueryResultCallback.callCallback(QueryResultCallback.java:64) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:446) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:440) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:127) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:123) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375) at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:217) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:204) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:281) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:579) at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:397) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} The IllegalStateException is passed into the callback when executing the following call chain: {code} searchCollection.find() .limit(10). .into(resultList, callback); {code}

    JIRA | 2 years ago | Jeff Yemin
    java.lang.IllegalStateException: Attempted to decrement the reference count below 0
  2. 0

    We are using the mongoDB async java driver version 3.0.1. When doing performance tests (only reads) with a lot of concurrent requests to the driver, we sometimes encounter the following exception: {code} java.lang.IllegalStateException: Attempted to decrement the reference count below 0 at com.mongodb.binding.AbstractReferenceCounted.release(AbstractReferenceCounted.java:39) at com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.release(AsyncClusterBinding.java:113) at com.mongodb.operation.AsyncQueryBatchCursor.killCursor(AsyncQueryBatchCursor.java:154) at com.mongodb.operation.AsyncQueryBatchCursor.close(AsyncQueryBatchCursor.java:79) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:93) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:141) at com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:130) at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:90) at com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130) at com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:51) at com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:45) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.async.client.MongoClientImpl$2$1.onResult(MongoClientImpl.java:129) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.operation.OperationHelper$ConnectionReleasingWrappedCallback.onResult(OperationHelper.java:140) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:433) at com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:427) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:171) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.QueryResultCallback.callCallback(QueryResultCallback.java:64) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48) at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:446) at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:440) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:127) at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:123) at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53) at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375) at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417) at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577) at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444) at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:217) at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:204) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:281) at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:579) at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:397) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} The IllegalStateException is passed into the callback when executing the following call chain: {code} searchCollection.find() .limit(10). .into(resultList, callback); {code}

    JIRA | 2 years ago | Jeff Yemin
    java.lang.IllegalStateException: Attempted to decrement the reference count below 0
  3. 0

    How can I cope with "IllegalStateException: BeanFactory not initialized or already closed"?

    Stack Overflow | 6 years ago | user569825
    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    issues in spring petclinic applicaiton

    Stack Overflow | 4 years ago | user2216702
    java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: Root WebApplicationCon text: startup date [Wed Mar 27 11:31:56 CDT 2013]; root of context hierarchy at org.springframework.context.support.AbstractApplic ationContext.getApp licationEventMulticaster(AbstractApplicationContex t.java:347) [spring-context-3. 2.2.RELEASE.jar:3.2.2.RELEASE] at org.springframework.context.support.AbstractApplic ationContext.publis hEvent(AbstractApplicationContext.java:334) [spring-context-3.2.2.RELEASE.jar:3. 2.2.RELEASE] at org.springframework.context.support.AbstractApplic ationContext.doClos e(AbstractApplicationContext.java:1049) [spring-context-3.2.2.RELEASE.jar:3.2.2. RELEASE] at org.springframework.context.support.AbstractApplic ationContext.close( AbstractApplicationContext.java:1010) [spring-context-3.2.2.RELEASE.jar:3.2.2.RE LEASE] at org.springframework.web.context.ContextLoader.clos eWebApplicationCont ext(ContextLoader.java:558) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE] at org.springframework.web.context.ContextLoaderListe ner.contextDestroye d(ContextLoaderListener.java:143) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE] at org.apache.catalina.core.StandardContext.listenerS top(StandardContext .java:4831) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.StandardContext.stopInter nal(StandardContext .java:5478) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.util.LifecycleBase.stop(Lifecy cleBase.java:232) [ tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:160) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase. java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase. java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30] at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303) [n a:1.6.0_20] at java.util.concurrent.FutureTask.run(FutureTask.jav a:138) [na:1.6.0_20 ] at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExec utor.java:886) [na:1.6.0_20] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor .java:908) [na:1.6.0_20]
  6. 0

    Porting project JBoss AS 6 to JBoss AS 7

    Stack Overflow | 5 years ago | Rounak
    java.lang.IllegalStateException: Application was not properly initialize d at startup, could not find Factory: javax.faces.application.ApplicationFactory at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.jav a:894) [jsf-api.jar:] at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:319) [jsf-api .jar:] at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext .java:112) [jsf-impl.jar:] at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureList ener.java:325) [jsf-impl.jar:] at org.apache.catalina.core.StandardContext.listenerStop(StandardContext .java:3465) [jbossweb-7.0.1.Final.jar:7.0.2.Final] at org.apache.catalina.core.StandardContext.stop(StandardContext.java:39 70) [jbossweb-7.0.1.Final.jar:7.0.2.Final] at org.apache.catalina.core.StandardContext.start(StandardContext.java:3 888) [jbossweb-7.0.1.Final.jar:7.0.2.Final] at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentS ervice.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(Se rviceControllerImpl.java:1824) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceCont rollerImpl.java:1759) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. java:1110) [:1.7.0] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:603) [:1.7.0]
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    Attempted to decrement the reference count below 0

    at com.mongodb.binding.AbstractReferenceCounted.release()
  2. MongoDB Java Driver
    AsyncQueryBatchCursor.next
    1. com.mongodb.binding.AbstractReferenceCounted.release(AbstractReferenceCounted.java:39)
    2. com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.release(AsyncClusterBinding.java:113)
    3. com.mongodb.operation.AsyncQueryBatchCursor.killCursor(AsyncQueryBatchCursor.java:154)
    4. com.mongodb.operation.AsyncQueryBatchCursor.close(AsyncQueryBatchCursor.java:79)
    5. com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:93)
    5 frames
  3. com.mongodb.async
    OperationIterable$4.onResult
    1. com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130)
    2. com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30)
    3. com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:141)
    4. com.mongodb.async.client.OperationIterable$4.onResult(OperationIterable.java:130)
    4 frames
  4. MongoDB Java Driver
    AsyncQueryBatchCursor.next
    1. com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:90)
    1 frame
  5. com.mongodb.async
    OperationIterable$1.onResult
    1. com.mongodb.async.client.OperationIterable.loopCursor(OperationIterable.java:130)
    2. com.mongodb.async.client.OperationIterable.access$000(OperationIterable.java:30)
    3. com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:51)
    4. com.mongodb.async.client.OperationIterable$1.onResult(OperationIterable.java:45)
    4 frames
  6. MongoDB Java Driver
    ErrorHandlingResultCallback.onResult
    1. com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
    1 frame
  7. com.mongodb.async
    MongoClientImpl$2$1.onResult
    1. com.mongodb.async.client.MongoClientImpl$2$1.onResult(MongoClientImpl.java:129)
    1 frame
  8. MongoDB Java Driver
    AsynchronousSocketChannelStream$BasicCompletionHandler.completed
    1. com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
    2. com.mongodb.operation.OperationHelper$ConnectionReleasingWrappedCallback.onResult(OperationHelper.java:140)
    3. com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:433)
    4. com.mongodb.operation.FindOperation$2$1.onResult(FindOperation.java:427)
    5. com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
    6. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:171)
    7. com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
    8. com.mongodb.connection.QueryResultCallback.callCallback(QueryResultCallback.java:64)
    9. com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48)
    10. com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23)
    11. com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:446)
    12. com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:440)
    13. com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:127)
    14. com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:123)
    15. com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
    16. com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375)
    17. com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65)
    18. com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417)
    19. com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386)
    20. com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555)
    21. com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514)
    22. com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577)
    23. com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561)
    24. com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
    25. com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441)
    26. com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:217)
    27. com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:204)
    27 frames
  9. Java RT
    Thread.run
    1. sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
    2. sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:281)
    3. sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:579)
    4. sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:397)
    5. sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    6. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    7. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    8. java.lang.Thread.run(Thread.java:745)
    8 frames