Found the source of my connection leak, and it may or may not be related to the 
above post, so I'll put it here in case anyone is interested.

My web service was creating a JbpmContext and calling getConnection() to get a 
connection.  My assumption was that this was a shortcut for 
Jbpm.getSession().getConnection(), which is not exactly true.  Lookin at 
DbPersistenceService, they end up being essentially the same thing unless that 
JNDI data source name property is somehow registered on the 
DbPersistenceService.  I then created a JDBC PreparedStatement on the 
connection, executed some arbitrary SQL, and closed the JbpmContext, thinking 
that when the JbpmContext was closed, the Hibernate session would commit and 
close and the underlying connection would be taken care of.

As it turns out, TxConnectionManager.end() was called (which tells me the 
connection.commit() method was called) but the 
TxConnectionManager.connectionClosed() method was never invoked.  I suspect 
that Hibernate has some magic in the Transaction.commit() method that handles 
JTA transactions if there was work done during the transaction (in my case 
Hibernate didn't know about the work being done because I used an external JDBC 
PreparedStatement).  I came to this conclusion for two reasons:

1. Using a Hibernate SQLQuery instead of a PreparedStatement fixed the 
connection leak
2. Using PreparedStatements does not cause a connection leak if JTA is not used

Does using JTA imply exclusive use of the jBPM and/or Hibernate APIs?  Is it 
incorrect to mix JDBC and Hibernate calls in a JTA transaction?  Was there 
another step I needed to take (such as an exclusive JTA commit)?

- Jesse

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3932225#3932225

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3932225


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to