views:

226

answers:

2

Hello all I have a simple Spring application which will not end as there is still a reference left to org.enhydra.jdbc.pool.PoolKeeper. I include all the references I feel are revelant below does it look ok and has anyone experienced this before?

I ran jstack to see what non daemon threads where running and found the following.

"Thread-1" prio=10 tid=0x00007f89b03d8000 nid=0x755 in Object.wait() [0x00007f89bc243000]    java.lang.Thread.State: TIMED_WAITING (on object monitor)  at java.lang.Object.wait(Native Method)
    - waiting on <0x00007f89ec57de00> (a org.enhydra.jdbc.pool.PoolKeeper)  at org.enhydra.jdbc.pool.PoolKeeper.run(PoolKeeper.java:55)
    - locked <0x00007f89ec57de00> (a org.enhydra.jdbc.pool.PoolKeeper)  at java.lang.Thread.run(Thread.java:619)

Now I am confused as to why this is happening I include relevant parts of my JPA configuration

<bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource"
 destroy-method="shutdown">
 <property name="transactionManager" ref="jotm" />
 <property name="driverName" value="${jdbc.driverClassName}"/>
 <property name="url" value ="${jdbc.url}"/>
 <property name="user" value="${jdbc.username}"/>
 <property name="password" value="${jdbc.password}"/>
</bean>
<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
 destroy-method="shutdown">
 <property name="dataSource" ref="innerDataSource"/>
 <property name="user" value="${jdbc.username}" />
 <property name="password" value="${jdbc.password}" />
 <property name="maxSize" value="100" />
 <!-- test your jdbc connection before using it -->
 <property name="checkLevelObject" value="${jdbc.checkLevelObject}"/>
 <property name="jdbcTestStmt" value="${jdbc.jdbcTestStmt}"/>
</bean>

Thanks Paul

A: 

Your Spring file looks correct to me based on the enhydra javadoc (which is sparse on details). I did see a stopPool() method in the API. Perhaps try that in your destroy-method?

SingleShot
Thanks for the suggestion no joy.
Paul Whelan
+1  A: 

Web applications typically configure a Spring application context using ContextLoaderListener, which closes the application context when the Web application is stopped.

Standalone Java applications have to call the close method on the application context, which invokes the methods configured in the destroy-method attribute while destroying the beans. Alternatively, call the registerShutdownHook method to register a shutdown hook that closes the application context on JVM shutdown.

Jim Huang
Thanks JimI was looking for the close method but as I was storing the ClassPathXmlApplicationContext in a ApplicationContext and not a ConfigurableApplicationContext I never saw the method.
Paul Whelan