Tomcat has to prevent H2 from leaking memory

1,647 views
Skip to first unread message

Geert Jan Alsem

unread,
Mar 31, 2012, 1:49:28 PM3/31/12
to h2-da...@googlegroups.com
I'm setting up a web app on Tomcat. Using H2 seems to work great, except for a warning that keeps popping up in the Tomcat logs:

SEVERE: The web application [/TestApp] registered the JDBC driver [org.h2.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

At first I had more similar warnings about H2 memory leaks, but they went away when I registered the DbStarter listener in my web.xml:

...
<context-param>
<param-name>db.url</param-name>
<param-value>jdbc:h2:~/test</param-value>
</context-param>
<context-param>
<param-name>db.user</param-name>
<param-value>test</param-value>
</context-param>
<context-param>
<param-name>db.password</param-name>
<param-value>test</param-value>
</context-param>
<listener>
<listener-class>org.h2.server.web.DbStarter</listener-class>
</listener>
...

But the warning I mentioned above remains. Is this normal, or am I forgetting something?

Jim

unread,
May 23, 2012, 7:01:41 AM5/23/12
to H2 Database
I think this is somewhat similar to my problem.
Check my thread: http://groups.google.com/group/h2-database/browse_thread/thread/d4e7e2944969ad0c

Thomas Mueller

unread,
May 24, 2012, 1:16:30 PM5/24/12
to h2-da...@googlegroups.com
Hi,

I believe this is related to:

http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered

I'm not sure if it's a good idea to manually unregister the driver
when the application is stopped, it might work. Using a connection
pool is more complicated, and might also not solve the problem. Of
course you could simply ignore this message.

Regards,
Thomas
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to h2-database...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
>
Reply all
Reply to author
Forward
0 new messages