+

Search Tips | Advanced Search

Connection pool errors while trying to create a JMS Context

If an error occurs while we are trying to create a JMS Context, it is possible to determine from the error message if the top-level pool or lower-level pool had the issue.


How pools are used for Contexts

When using Connection and Sessions, there are pools for each type of object; a similar model is followed for Contexts.

A typical application that uses distributed transactions involves both messaging and non-messaging workloads in the same transaction.

Assuming that no work is currently working, and the application makes its first createConnection method call, a context facade or proxy is created in the equivalent of the connection pool (the top-level pool). Another object is created in the equivalent of the session pool. This second object encapsulates the underlying JMS Context (lower-level pool).

Pooling, as a concept, is used to permit an application to scale. Many threads are able to access a constrained set of resources. In this example, another thread will execute the createContext method call to get a context from the pool. Should other threads still be doing messaging work, then the top-level pool is expanded to provide an additional context for the requesting thread.

In the case where a thread requests a context and the messaging work has completed but the non-messaging work has not, so the transaction is not complete, the lower-level pool is expanded. The top-level context proxy remains assigned to the transaction until that transaction is resolved, so cannot be assigned to another transaction.

In the case of the lower pool becoming full, this means that the non-messaging work is taking potentially a long time.

In the case of the top-level pool becoming full, this means that the overall messaging work is taking a while and the pool should be expanded.


Identifying which pool an error originated from

We can determine the pool in which an error originated from the error message text:

  • For the top-level pool, the message text is Failed to create context. This message means that the top-level pool is full of Context-proxy objects, all of which have currently running transactions that are performing messaging.
  • For the lower-level pool, the message text is Failed to set up new JMSContext. This message means that although a connect-proxy is available, it is still necessary to wait for non-messaging work to complete.


Top-level pool example

***********************[8/19/16 10:10:48:643 UTC] 000000a2
    LocalExceptio E CNTR0020E: EJB threw an unexpected (non-declared)  exception during
    invocation of method "onMessage" on bean
    "BeanId(SibSVTLiteMDB#SibSVTLiteMDBXA_RecoveryEJB_undeployed.jar#QueueReceiver,  null)".
    Exception data: javax.jms.JMSRuntimeException: Failed to create context       
      at com.ibm.ejs.jms.JMSCMUtils.mapToJMSRuntimeException(JMSCMUtils.java:522)        
      at com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContextInternal(JMSConnectionFactoryHandle.java:449) 
      at com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContext(JMSConnectionFactoryHandle.java:335) 
      at sib.test.svt.lite.mdb.xa.SVTMDBBase.sendReplyMessage(SVTMDBBase.java:554)   
      at sib.test.svt.lite.mdb.xa.QueueReceiverBean.onMessage(QueueReceiverBean.java:128)     
      at sib.test.svt.lite.mdb.xa.MDBProxyQueueReceiver_37ea5ce9.onMessage(MDBProxyQueueReceiver_37ea5ce9.java) 
      at com.ibm.mq.connector.inbound.MessageEndpointWrapper.onMessage(MessageEndpointWrapper.java:151) 
      at com.ibm.mq.jms.MQSession$FacadeMessageListener.onMessage(MQSession.java:129) 
      at com.ibm.msg.client.jms.internal.JmsSessionImpl.run(JmsSessionImpl.java:3236) 
      at com.ibm.mq.jms.MQSession.run(MQSession.java:937)        
      at com.ibm.mq.connector.inbound.ASFWorkImpl.doDelivery(ASFWorkImpl.java:104)        
      at com.ibm.mq.connector.inbound.AbstractWorkImpl.run(AbstractWorkImpl.java:233)        
      at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:668)        
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
    Caused by: com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009       
      at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1783)        
      at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3896)        
      at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3116)        
      at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548)     
      at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031) 
      at com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContextInternal(JMSConnectionFactoryHandle.java:443) 
          ... 12 more


Lower-level pool example

***********************
[8/19/16 9:44:44:754 UTC] 000000ac SibMessage W   [:] CWSJY0003W: MQJCA4004: Message delivery to an MDB
    'sib.test.svt.lite.mdb.xa.MDBProxyQueueReceiver_37ea5ce9@505d4b68
(BeanId(SibSVTLiteMDB#SibSVTLiteMDBXA_RecoveryEJB_undeployed.jar#QueueReceiver, null))' failed with exception: 
'nested exception is: javax.jms.JMSRuntimeException: Failed to set up new JMSContext'.
ˆC[root@username-instance-2 server1]# vi SystemOut.log                               
                  :com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:668)                       
                  : com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
    Caused by [1] --> Message : javax.jms.JMSRuntimeException: Failed to set up new JMSContext       
               Class : class javax.jms.JMSRuntimeException             
               Stack : com.ibm.ejs.jms.JMSCMUtils.mapToJMSRuntimeException(JMSCMUtils.java:522)           
                  : com.ibm.ejs.jms.JMSContextHandle.setupInternalContext(JMSContextHandle.java:241)     
                  : com.ibm.ejs.jms.JMSManagedConnection.getConnection(JMSManagedConnection.java:783)     
                  : com.ibm.ejs.j2c.MCWrapper.getConnection(MCWrapper.java:2336)                   
                  : com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1064)      
                  : com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContextInternal(JMSConnectionFactoryHandle.java:443) 
                  : com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContext(JMSConnectionFactoryHandle.java:335) 
                  : sib.test.svt.lite.mdb.xa.SVTMDBBase.sendReplyMessage(SVTMDBBase.java:554)           
                  : sib.test.svt.lite.mdb.xa.QueueReceiverBean.onMessage(QueueReceiverBean.java:128)      
                  : sib.test.svt.lite.mdb.xa.MDBProxyQueueReceiver_37ea5ce9.onMessage(MDBProxyQueueReceiver_37ea5ce9.java:-1) 
                  : com.ibm.mq.connector.inbound.MessageEndpointWrapper.onMessage(MessageEndpointWrapper.java:151) 
                  : com.ibm.mq.jms.MQSession$FacadeMessageListener.onMessage(MQSession.java:129)         
                  : com.ibm.msg.client.jms.internal.JmsSessionImpl.run(JmsSessionImpl.java:3236)         
                  : com.ibm.mq.jms.MQSession.run(MQSession.java:937)     
                  : com.ibm.mq.connector.inbound.ASFWorkImpl.doDelivery(ASFWorkImpl.java:104)           
                  : com.ibm.mq.connector.inbound.AbstractWorkImpl.run(AbstractWorkImpl.java:233)         
                  : com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:668) 
                  : com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)     
    Caused by [2] --> Message : com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009 
               Class : class com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException                       
               Stack : com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1783)     
                  : com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3840)                     
                  : com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3116)         
                  : com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548)     
                  : com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031)     
                  : com.ibm.ejs.jms.JMSContextHandle.setupInternalContext(JMSContextHandle.java:222)     
                  : com.ibm.ejs.jms.JMSManagedConnection.getConnection(JMSManagedConnection.java:783)     
                  : com.ibm.ejs.j2c.MCWrapper.getConnection(MCWrapper.java:2336)                   
                  : com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1064)      
                  : com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContextInternal(JMSConnectionFactoryHandle.java:443) 
                  : com.ibm.ejs.jms.JMSConnectionFactoryHandle.createContext(JMSConnectionFactoryHandle.java:335) 
                  : sib.test.svt.lite.mdb.xa.SVTMDBBase.sendReplyMessage(SVTMDBBase.java:554)           
                  : sib.test.svt.lite.mdb.xa.QueueReceiverBean.onMessage(QueueReceiverBean.java:128)      
                  : sib.test.svt.lite.mdb.xa.MDBProxyQueueReceiver_37ea5ce9.onMessage(MDBProxyQueueReceiver_37ea5ce9.java:-1) 
                  : com.ibm.mq.connector.inbound.MessageEndpointWrapper.onMessage(MessageEndpointWrapper.java:151) 
                  : com.ibm.mq.jms.MQSession$FacadeMessageListener.onMessage(MQSession.java:129)         
                  : com.ibm.msg.client.jms.internal.JmsSessionImpl.run(JmsSessionImpl.java:3236)         
                  : com.ibm.mq.jms.MQSession.run(MQSession.java:937)     
                  : com.ibm.mq.connector.inbound.ASFWorkImpl.doDelivery(ASFWorkImpl.java:104)           
                  : com.ibm.mq.connector.inbound.AbstractWorkImpl.run(AbstractWorkImpl.java:233)         
                  : com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:668) 
                  : com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
Parent topic: JMS connection pool error handling

Last updated: 2020-10-04