0

我正在使用 Spring、Hibernate 和 BoneCP 实现一个应用程序。当我调用 Tomcat 的关闭脚本时,我看到这样的错误

The web application [/REST] appears to have started a thread named [BoneCP-release-thread-helper-thread] but has failed to stop it. This is very likely to create a memory leak.

当我看到我的日志时,我没有看到“正在关闭连接池......”,所以我假设我在这里遗漏了一些东西。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
   http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-1.5.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
   xmlns:context="http://www.springframework.org/schema/context">


<bean id="LookupService" class="com.appserver.rest.LookupService">
    <property name="userManager" ref="UserManager"></property>
    <property name="groupManager" ref="GroupManager"></property>
    <property name="messageManager" ref="MessageManager"></property>
    <property name="tokenManager" ref="TokenManager"></property>
    <property name="accessManager" ref="AccessManager"></property>
    <property name="rosterManager" ref="RosterManager"></property>
</bean>
<bean id="LookupServiceV2" class="com.appserver.rest.LookupServiceV2"
    parent="LookupService">
</bean>
<bean id="UserManager" class="com.appserver.rest.UserManager">
    <constructor-arg index="0">
        <ref bean="authManager" />
    </constructor-arg>
</bean>
<bean id="GroupManager" class="com.appserver.rest.GroupManager">
    <constructor-arg index="0">
        <ref bean="authManager" />
    </constructor-arg>
</bean>
<bean id="MessageManager" class="com.appserver.rest.MessageManager">
</bean>
<bean id="TokenManager" class="com.appserver.rest.TokenManager">
    <constructor-arg index="0">
        <ref bean="secureRandom" />
    </constructor-arg>
</bean>
<bean id="authManager" class="com.appserver.rest.AuthenticationManager">
    <constructor-arg index="0">
        <ref bean="secureRandom" />
    </constructor-arg>
</bean>
<bean id="AccessManager" class="com.appserver.rest.AccessManager">
</bean>
<bean id="RosterManager" class="com.appserver.rest.RosterManager">
</bean>
<bean id="secureRandom" class="java.security.SecureRandom">
</bean>
<bean id="messageDeleteScheduler" class="com.appserver.schema.MessageDeleteScheduler" />

<bean id="messageDeleteJob"
    class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="messageDeleteScheduler" />
    <property name="targetMethod" value="scheduleMessageDeletion" />
</bean>
<bean id="messageDeleteTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
    <property name="jobDetail" ref="messageDeleteJob" />
    <property name="repeatInterval" value="3600000" />
    <property name="startDelay" value="1000" />
</bean>

<bean id="quartz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" destroy-method="destroy" >
    <property name="jobDetails">
        <list>
            <ref bean="messageDeleteJob" />
        </list>
    </property>

    <property name="triggers">
        <list>
            <ref bean="messageDeleteTrigger" />
        </list>
    </property>
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
    autowire="autodetect">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.appserver.schema.GroupDB</value>
            <value>com.appserver.schema.UserDB</value>
            <value>com.appserver.schema.MessageDB</value>
            <value>com.appserver.schema.UserBlockDB</value>
            <value>com.appserver.schema.GroupUserMapperDB</value>
        </list>

    </property> 
    <property name="hibernateProperties">
        <props>
            <!-- <prop key="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</prop>  -->
            <!-- <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
            <prop key="hibernate.connection.url">jdbc:mysql://localhost/testdb</prop>
            <prop key="hibernate.connection.username">alpha1</prop>
            <prop key="hibernate.connection.password">r0cktheworld</prop>
            <prop key="hibernate.connection.pool_size">50</prop>
             -->
            <prop key="hibernate.show_sql">true</prop>

            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
            <prop key="hibernate.current_session_context_class">thread</prop>
            <prop key="hibernate.globally_quoted_identifiers">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EHCacheProvider</prop>
            <!-- <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop> -->
            <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
            </prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_structured_entries">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <!-- this is connection provider -->
            <!-- and this is how you configure it -->


            <prop key="jadira.usertype.autoRegisterUserTypes">true</prop>
            <prop key="jadira.usertype.databaseZone">jvm</prop>
            <prop key="jadira.usertype.javaZone">jvm</prop>

        </props>
    </property>
</bean>

<!-- Spring bean configuration. Tell Spring to bounce off BoneCP -->
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
            <property name="targetDataSource">
                <ref local="mainDataSource" />
            </property>
        </bean>

 <bean id="mainDataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
            <property name="driverClass" value="com.mysql.jdbc.Driver" />
            <property name="jdbcUrl" value="jdbc:mysql://localhost/dbrocker" />
            <property name="username" value="root"/>
            <property name="password" value="root123"/>
            <property name="idleConnectionTestPeriod" value="60"/>
            <property name="idleMaxAge" value="240"/>      
            <property name="maxConnectionsPerPartition" value="60"/>
            <property name="minConnectionsPerPartition" value="20"/>
            <property name="partitionCount" value="3"/>
            <property name="acquireIncrement" value="10"/>                              
            <property name="statementsCacheSize" value="50"/>
            <property name="releaseHelperThreads" value="3"/>
 </bean>
 <context:annotation-config/>

谢谢

4

1 回答 1

1

这是一个已知的问题。请参阅https://code.google.com/p/guava-libraries/issues/detail?id=92。尝试使用包含 14.0.1 版本的 guava 的 bonecp-0.8.0-rc2 的快照版本,其中修复了 guava Finalizer 线程未关闭的问题。

您可以从此处获取快照 -> https://oss.sonatype.org/content/repositories/snapshots/com/jolbox/bonecp/0.8.0-rc2-SNAPSHOT/

于 2013-07-24T04:34:11.100 回答