Details
Description
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.
Issue Links
- depends upon
-
CASTOR-1345
Refactor DatabaseImpl
-
I am currently in the progress of finalizing a patch that refactores DatabaseImpl into something more meaningful, trying to cleanup that if (transaction == null) business and replacing it with a proper strategy. Can we please delay this until I have committed
CASTOR-1345?In addition, I believe that the patch supplied (whilst dealing with a symptom) does not really tackle the root cause of this problem. I agree that above scenario should not happen at all, and that we should try to fix this. But first I need to dig up an existing Jira entry that provides a detailed description of the underlying (read real) problem, and take it from there.