Bruce,
I have been testing around with an amount of code changes that could be
fixing this problem in my application.
As Werner suggested I moved back the db.commit() back into the try/catch
block and added results.close() aswell. Only the db.close() is located
in the appending finally block (with an additional try/catch block for it).
However I made an interesting observation. I started up the server
application and the Tomcat web frontend, used it for some minutes
without any errors and the left it idle for a good amount of time (like
10 to 20 minutes). When I redo a request that includes a database
operation via castor it crashes - complaining that a db connection has
already been closed and I can't call another close() operation on it:
"java.sql.SQLException: Connection.close() has already been
called. Invalid operation in this state."
That sounds to me like some type of timeout, doesn't it?
Once this exception occurs all following db actions result in exceptions.
Now, _every_ database operation code snippet looks like this (I revamped
all needed parts). I have 4 Manager classes designed as Singletons that
do the whole db stuff. All classes receive a JDO object via the
getInstance()/private constructor method:
public class TokenManager extends Manager {
private JDO jdo = null;
private static TokenManager tmObj = null;
private static Logger logger;
private TokenManager(JDO jdo) {
logger = logger.getLogger("pce.core.engine.TokenManager");
this.jdo = jdo;
}
public static TokenManager getInstance(JDO jdo) {
if (tmObj == null)
tmObj = new TokenManager(jdo);
return tmObj;
}
}
...
...
// [snippet of a single method that uses the global JDO object ]
...
Database db = null;
OQLQuery testOql = null;
QueryResults results = null;
try {
db = jdo.getDatabase();
db.begin();
testOql = db.getOQLQuery(" ... " );
results = testOql.execute();
// ... do something ...
testOql.close();
testOql = null;
results.close();
results = null;
db.commit();
} catch (PersistenceException e) {
logger.error("...", e);
} finally {
try {
db.close();
} catch (PersistenceException e) {
logger.error("...", e);
}
}
...
I even did a test and removed every db.close() in the whole code, the
connections in the pool are constantly raising of course but I also get
the "java.sql.SQLException: Connection.close() has already been
called. Invalid operation in this state."-exception.
However the interesting thing is the "timeout" without any
database/application activity. pce.core.engine. Maybe this has to do
with my PoolMan configuration aswell? I can supply this aswell if desired.
A question at the end:
Would it be necessary to add a
if (!db.isClosed)
before the db.close(); call in the finally block?
Cheers,
Jens
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage!
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev