IJ000609: Attempt to return connection twice in EAP 6
Issue
- We've struggle with a problem which shows up as the following exception
IJ000609: Attempt to return connection twice: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@44405f2e[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@52c9fe04 connection handles=0 lastUse=1460708280963 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@63542a07 pool internal context=SemaphoreArrayListManagedConnectionPool@731fd564[pool=TargenioDS] xaResource=LocalXAResourceImpl@5e28e803[connectionListener=44405f2e connectionManager=2d0680e5 warned=false currentXid=null productName=Microsoft SQL Server productVersion=11.00.6020 jndiName=java:jboss/datasources/testDS] txSync=null]: java.lang.Throwable: STACKTRACE
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.returnConnection(SemaphoreArrayListManagedConnectionPool.java:554)
-
We found link Connectionmanager attempts to return connection twice about this error, It simply says, that this is an application problem. Because we cannot see an implementation error at first sight.
-
The below code causing this error is a simple timer bean that manages transactions by itself. Within a loop, transactions are created and finished. Simplified the situation is this.
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class TestBean1 extends TestBean implements Test {
@Resource
context context;
@Timeout
public void processes(Timer timer) {
...
try {
method1();
}
catch (Exception e) {
logException(e, null);
throw new EJBException(e);
}
}
protected void method1()
throws SQLException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException,
HeuristicRollbackException, SystemException, NotSupportedException
{
....
for (exList a : someLists) {
try {
...
method2();
}
catch (CustomException e) {
logException(e, null);
}
}
}
protected void method2()
throws SQLException,CustomException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException,
HeuristicRollbackException, SystemException, NotSupportedException
{
UserTransaction transaction = context.getUserTransaction();
transaction.begin();
try {
// call a couple of service methods that participate in the transaction just created.
...
transaction.commit();
}
catch (CustomException2 e) {
// here the error seems to arise:
transaction.rollback();
}
finally {
// finally block
}
}
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.4.6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.