tolyen
unread,Aug 22, 2008, 6:21:38 AM8/22/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hello,
I'm putting together a simple web application that has H2 in embedded
mode, Spring and Hibernate. I've got everything working now, but the
problem is that the database won't shut down gracefully when Tomcat
shuts down. I have defined the db properties in hibernate.cfg.xml and
use that to create sessionFactory in Spring config. But when the
servlet container is shut down, I have not yet found a way to shutdown
the database properly. First, there are some stacktraces in the logs
when Tomcat shuts down, like:
INFO: Illegal access: this web application instance has been stopped
already. Could not load org.h2.util.CacheObject$1. The eventual
following stack trace is caused by an error thrown for debugging
purposes as well as to attempt to terminate the thread which caused
the illegal access, and has no functional impact.
java.lang.IllegalStateException
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1273)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)
at org.h2.util.CacheObject.sort(CacheObject.java:65)
at org.h2.store.DiskFile.flush(DiskFile.java:436)
at org.h2.index.BtreeIndex.flush(BtreeIndex.java:190)
at org.h2.index.BtreeIndex.close(BtreeIndex.java:205)
at org.h2.table.TableData.close(TableData.java:83)
at org.h2.engine.Database.close(Database.java:1024)
at org.h2.engine.Database.removeSession(Database.java:963)
at org.h2.engine.Session.close(Session.java:431)
at org.h2.engine.Database.close(Database.java:996)
at org.h2.engine.DatabaseCloser.run(DatabaseCloser.java:73)
and on top of that, the lock file, test.lock.db is not even deleted,
so I have to delete it manually when I want to restart Tomcat. This
makes me a little worried that there might be issues with data
corruption etc. if I continue this kind of startup/shutdown-procedure.
So what is the best practice for stopping the database in a servlet
environment (with Hibernate) when using embedded mode?
Also, interestingly, all the auto increment counters in tables seem to
increment by 30 every time I restart Tomcat, what might be the cause
of this?