Upon performing a begin and commit/rollback on a local transaction around every entity bean call that isn't taking place in an official JTA transaction, the OpenEJB team sees the following:
Mar 9, 2006 11:19:48 AM org.exolab.castor.jdo.engine.DatabaseImpl.finalize
WARNING: An open database instance
(org.exolab.castor.jdo.engine.DatabaseImpl@a8f250:Local_TX_Database) against database: Local_TX_Database has been encountered. This instance will be closed now to release system resources. Please consider changing your code as well to enforce that all database connections are closed after use.SQL executed, but not closed:null
The code that does that is here:
OpenEJB is using local transactions which is LocalTransactionContext and:
1. The connection is closed immediately after commit()/rollback()
2. But the closeConnections() method is an empty, no-op impl.
So the DatabaseImpl.finalize method checks to see if you are using LocalTransactionContext and makes a point to reprimand you for not calling close, then the closeConnections() method of LocalTransactionContext does nothing anyway.
If you call commit/rollback responsibly on a DatabaseImpl with a LocalTransactionContext, calling close and the log message are unnecessary. Strangely, OpenEJB even runs into thread deadlock issues upon adding a close call after db.commit/rollback.
Attached is a patch that will prevent this warning from being output unnecessarily.