0

我已经面临这个问题一段时间了。我的配置如下

<!-- Load Properties Files -->
<context:property-placeholder location="classpath:*-${environment}.properties" ignore-unresolvable="true"/>

<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="idleConnectionTestPeriodInMinutes" value="${boneCP.idleConnectionTestPeriodInMinutes}"/>
        <property name="idleMaxAgeInMinutes" value="${boneCP.idleMaxAgeInMinutes}"/>
        <property name="maxConnectionsPerPartition" value="${boneCP.maxConnectionsPerPartition}"/>
        <property name="minConnectionsPerPartition" value="${boneCP.minConnectionsPerPartition}"/>
        <property name="partitionCount" value="${boneCP.partitionCount}"/>
        <property name="acquireIncrement" value="${boneCP.acquireIncrement}"/>
        <property name="statementsCacheSize" value="${boneCP.statementsCacheSize}"/>
        <property name="lazyInit" value="true"/>
        <property name="maxConnectionAgeInSeconds" value="${boneCP.maxConnectionAgeInSeconds}"/>
</bean>

该项目在Tomcat 7上运行

在本地机器上,项目部署没有错误,开发服务器也一样。不幸的是,该项目不能再部署在开发服务器上(服务器配置保持不变),而本地机器仍然很好。每次我在开发服务器上部署项目时,Tomcat 都会挂在 INFO: Deploying web application archive /etc/tomcat/webapps/project.war 上。但如果我用真实值配置 BoneCP,一切都很好。

谁能告诉我它有什么问题?


原来是lazyInit问题。如果我注释掉它,服务器可以正常启动。但现在我面临着新的问题。Mybatis根本无法访问db,而本地机器100%正常。但不要抛出任何异常。但是当我停止服务器时,我发现了以下异常

INFO: Illegal access: this web application instance has been stopped already.  Could not load com.jolbox.bonecp.PoolUtil.  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:1600)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:94)
    at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:90)
    at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:540)
    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
    at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:66)

INFO: Illegal access: this web application instance has been stopped already.  Could not load org.apache.ibatis.reflection.ExceptionUtil.  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:1600)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:363)
    at sun.proxy.$Proxy15.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
    at sun.proxy.$Proxy45.selectByExample(Unknown Source)
4

1 回答 1

0

Well it could be many things but its most likely

  1. properties are not being replaced with the values you think
  2. the database number of connections has been exceeded or the wrong host
  3. A combination of 1 + 2

For #1 I would a make a separate bean that needs com.jolbox.bonecp.BoneCPDataSource as a dependency and have it print out the getters of BoneCPDataSource.

For #2 I would turn on as much logging as possible (see log4j or logback or whatever your logging framework is).

于 2013-02-07T19:52:54.123 回答