Problems with db-connections while shuting down tomcat

402 visningar
Hoppa till det första olästa meddelandet

bobm

oläst,
8 juli 2009 06:12:232009-07-08
till H2 Database
Hello,

i am using h2 with spring & struts 2. It works fine together, but one
problem occurs when i am closing tomcat.
It appears like tomcat is trying to close one of already closed
connections and got NullpointerException. I think the exception
results from wrong configuration of connectionpool or db.
Any idea?


My spring-configuration is:

<bean id="org.h2.tools.Server" class="org.h2.tools.Server"
scope="singleton" factory-method="createTcpServer" init-method="start"
destroy-method="stop">
<constructor-arg value="-tcp,-tcpAllowOthers,-web,-
webAllowOthers"/>
</bean>


<bean id="h2databasePoolingDataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-
method="close">
<property name="driverClass" value="org.h2.Driver"/>
<property name="jdbcUrl" value="jdbc:h2:./
xscache;DB_CLOSE_DELAY=0;TRACE_LEVEL_FILE=4"/>
<property name="user" value="sa"/>
<property name="password" value=""/>

<property name="maxPoolSize" value="5"/>
<property name="minPoolSize" value="2"/>
<property name="acquireIncrement" value="2"/>

<property name="maxConnectionAge" value="0"/>
<property name="preferredTestQuery" value="SELECT 1"/>
</bean>


The StackTrace was:

Preparing to destroy PooledConnection:
com.mchange.v2.c3p0.impl.NewPooledConnection@d7419b
DEBUG [Resource Destroyer in BasicResourcePool.close()]
(TraceWriterAdapter.java:56) - xscache:jdbc[6]
/**/conn14.close();
INFO [Resource Destroyer in BasicResourcePool.close()]
(TraceWriterAdapter.java:59) - xscache:jdbc[6]
/*SQL */ROLLBACK;
08.07.2009 11:51:45 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Exception in thread "Resource Destroyer in BasicResourcePool.close()"
java.lang.NullPointerException
at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable
(Log4jMLog.java:257)
at com.mchange.v2.resourcepool.BasicResourcePool$5.run
(BasicResourcePool.java:1181)
Exception in thread "Thread-22" java.lang.NullPointerException
at org.apache.log4j.helpers.PatternConverter.spacePad
(PatternConverter.java:106)
at org.apache.log4j.helpers.PatternConverter.format
(PatternConverter.java:82)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:503)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:
301)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:
159)
at org.apache.log4j.AppenderSkeleton.doAppend
(AppenderSkeleton.java:230)
at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders
(AppenderAttachableImpl.java:65)
at org.apache.log4j.Category.callAppenders(Category.java:203)
at org.apache.log4j.Category.forcedLog(Category.java:388)
at org.apache.log4j.Category.log(Category.java:853)
at org.slf4j.impl.Log4jLoggerAdapter.info
(Log4jLoggerAdapter.java:377)
at org.h2.message.TraceWriterAdapter.write
(TraceWriterAdapter.java:59)
at org.h2.message.Trace.info(Trace.java:178)
at org.h2.engine.Database.close(Database.java:1099)
at org.h2.engine.DatabaseCloser.run(DatabaseCloser.java:80)


Regards,
Bob

Thomas Mueller

oläst,
11 juli 2009 02:20:402009-07-11
till h2-da...@googlegroups.com
Hi,

I think this exception is caused by Tomcat that sets some (private)
static fields to null (using reflection) to solve some classloader
garbage collection problems.

H2 avoids to use such static fields, but it looks like Log4J does not.
One option is to _not_ use Log4J in H2 (not use TRACE_LEVEL_FILE=4).
Otherwise, you will need to find a solution specific to Log4J. You
will find out this is not related to H2 if you do a Google search for
"NullPointerException at
com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable
(Log4jMLog.java:257)"

Regards,
Thomas

bobm

oläst,
23 juli 2009 09:58:232009-07-23
till H2 Database
Hi Thomas,

thank you for your answer. I think i will reduce the log level, but
for the moment i am needing this option.

Best Regards,
Bob
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden