"oglueck" wrote : Maybe the connection somehow doesn't get returned to the pool in time or something. Subsequent Connections are taken from the TransactionLocal and not from the Pool , here is the code
| public ConnectionListener getConnection(Transaction trackByTransaction, Subject subject, ConnectionRequestInfo cri) | throws ResourceException | { | // Determine the pool key for this request | boolean separateNoTx = false; | if (noTxSeparatePools) | separateNoTx = clf.isTransactional(); | Object key = getKey(subject, cri, separateNoTx); | SubPoolContext subPool = getSubPool(key, subject, cri); | | InternalManagedConnectionPool mcp = subPool.getSubPool(); | | // Are we doing track by connection? | TransactionLocal trackByTx = subPool.getTrackByTx(); | | // Simple case | if (trackByTransaction == null || trackByTx == null) | { | ConnectionListener cl = mcp.getConnection(subject, cri); | if (traceEnabled) | dump("Got connection from pool " + cl); | return cl; | } | | // Track by transaction | try | { | trackByTx.lock(trackByTransaction); | } | catch (Throwable t) | { | JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t); | } | try | { | // Already got one | ConnectionListener cl = (ConnectionListener) trackByTx.get(trackByTransaction); | if (cl != null) | { | if (traceEnabled) | dump("Previous connection tracked by transaction " + cl + " tx=" + trackByTransaction); | return cl; | } | } | finally | { | trackByTx.unlock(trackByTransaction); | } | | // Need a new one for this transaction | // This must be done outside the tx local lock, otherwise | // the tx timeout won't work and get connection can do a lot of other work | // with many opportunities for deadlocks. | // Instead we do a double check after we got the transaction to see | // whether another thread beat us to the punch. | ConnectionListener cl = mcp.getConnection(subject, cri); | if (traceEnabled) | dump("Got connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction); | | // Relock and check/set status | try | { | trackByTx.lock(trackByTransaction); | } | catch (Throwable t) | { | mcp.returnConnection(cl, false); | if (traceEnabled) | dump("Had to return connection tracked by transaction " + cl + " tx=" + trackByTransaction + " error=" + t.getMessage()); | JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t); | } | try | { | // Check we weren't racing with another transaction | ConnectionListener other = (ConnectionListener) trackByTx.get(trackByTransaction); | if (other != null) | { | mcp.returnConnection(cl, false); | if (traceEnabled) | dump("Another thread already got a connection tracked by transaction " + other + " tx=" + trackByTransaction); | return other; | } | | // This is the connection for this transaction | cl.setTrackByTx(true); | trackByTx.set(cl); | if (traceEnabled) | dump("Using connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction); | return cl; | } | finally | { | trackByTx.unlock(trackByTransaction); | } | } | If you enabled track-connection-by-tx and you are getting the connections in applicaition in a transaction then the underlying connection should be same . You can try this code | InitialContext context = new InitialContext(); | DataSource ds = (DataSource)context.lookup("java:XAOracleDS"); | //UserTransaction utx = (UserTransaction)context.lookup("UserTransaction"); | //utx.begin(); | Connection con = ds.getConnection(); | Connection con1 = ds.getConnection(); | WrappedConnection wrap = (WrappedConnection)con; | WrappedConnection wrap1 = (WrappedConnection)con1; | out.println("UnderlyingConnection is :---> "+wrap.getUnderlyingConnection()+"<br>"); | out.println("Underlying Connection "+wrap1.getUnderlyingConnection()+"<br>"); | //utx.commit(); | con.close(); | con1.close(); | In the above code the underlying connections would be different because the transaction related code is commented , if you uncomment that part it will give you same underlying connection. So make sure that the part of code which is giving you different result is in transaction . View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104540#4104540 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104540 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user