C3P0使用出错!
网站今日又出现不能访问的原因:
日志如下:
[framework] 2008-09-18 18:36:05,109 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -46651078 [Timer-18] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1c17bd4 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
网上说是连接池的原因....
我的C3P0配置
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><property name="c3p0.min_size">20</property><property name="c3p0.max_size">200</property><property name="c3p0.time_out">1800</property><property name="c3p0.max_statement">100</property><property name="c3p0.validate">true</property>
对于以上错误,查阅了类似问题网友的解答:
一:http://www.iteye.com/topic/22160?page=3
<property name="c3p0.max_statement">100</property>
因为这里c3p0.max_statements写错了,所以设置无效,看下日志
[framework] 2008-09-18 06:32:48,906 - com.mchange.v2.c3p0.C3P0Registry -3257219 [TP-Processor1] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10] [framework] 2008-09-18 06:32:48,906 - com.mchange.v2.c3p0.management.ActiveManagementCoordinator -3257219 [TP-Processor1] WARN com.mchange.v2.c3p0.management.ActiveManagementCoordinator - A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources. [framework] 2008-09-18 06:32:49,015 - com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource -3257328 [TP-Processor1] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@7111383 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@a9b46d3 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2rysjs7wvr5h721dikp1v|1880048, idleConnectionTestPeriod -> 0, initialPoolSize -> 20, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 200, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 20, nestedDataSource ->
maxStatements的默认值为0
所以这种解决方法,感觉不行
二.http://yonguo.iteye.com/blog/120574
<property name="maxPoolSize" value="1"/> <property name="initialPoolSize" value="1"/>
因为数据库的连接数是有限的,每次应用启动C3p0都会占用数据库的连接来填充C3p0的连接池,而当数据库的资源被占光时就会因为无法获得共享资源而报死锁。
此方法可能有理,但没有测试.
三.http://www.iteye.com/problems/1082
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><!-- 初始化默认为20 --> <property name="initialPoolSize">1</property><property name="c3p0.min_size">1</property><property name="c3p0.max_size">500</property> <property name="c3p0.time_out">1800</property><!--每隔100秒检测连接是否可正常使用 --> <property name="c3p0.idle_test_period">1000</property> <property name="c3p0.validate">true</property><property name="hibernate.c3p0.acquire_increment">3</property>
对于这种配置也不知道结果会怎么样?
不知道有没有什么测试方法能马上看到效果?
其实hibernate里支持的c3p0参数没有多少.更多的还得在c3p0.property文件中定义
http://www.mchange.com/projects/c3p0/index.html#c3p0_properties
以上的配置文件,在运行后不久,直接出现打不开网页的问题..[framework] 2008-09-27 05:54:46,750 - com.mchange.v2.c3p0.management.ActiveManagementCoordinator -0 [TP-Processor3] WARN com.mchange.v2.c3p0.management.ActiveManagementCoordinator - A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources. [framework] 2008-09-27 05:54:47,687 - org.hibernate.cache.EhCacheProvider -937 [TP-Processor3] WARN org.hibernate.cache.EhCacheProvider - Could not find configuration [useCache]; [framework] 2008-09-27 13:25:41,484 - org.apache.struts.action.RequestProcessor -27483516 [TP-Processor15] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException [framework] 2008-09-27 16:45:27,671 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -39469703 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetecto[framework] 2008-09-27 16:45:38,171 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -39051421 [Timer-1] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@8772ca -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! [framework] 2008-09-27 16:45:38,171 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -39051421 [Timer-1] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@8772ca -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3Active Threads: 3Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a766f0 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@575786 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@332f00 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@52cd01com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1122c6Pool thread stack traces:Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]java.lang.Thread.sleep(Native Method)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]java.lang.Thread.sleep(Native Method)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]java.lang.Thread.sleep(Native Method)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) hod)com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) [framework] 2008-09-28 00:28:14,468 - org.apache.struts.action.RequestProcessor -67236500 [TP-Processor7] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.NumberFormatException [framework] 2008-09-28 01:30:58,375 - org.apache.struts.action.RequestProcessor -71000407 [TP-Processor14] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException [framework] 2008-09-28 09:42:08,828 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -100470860 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1cb365b -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! [framework] 2008-09-28 09:42:11,843 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -100473875 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1cb365b -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3Active Threads: 3Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@7b4d1 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1f03698 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1904275 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1fb4577com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@18dc83ecom.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1559dd1com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1ec1155Pool thread stack traces:Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:560)Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:560)Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:560) [framework] 2008-09-28 10:46:14,828 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -104316860 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1cb365b -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! [framework] 2008-09-28 10:46:14,828 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -104316860 [Timer-0] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1cb365b -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3Active Threads: 0Active Tasks: Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@19f9c21com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@1c3635dcom.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@b0ac18com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask@f27ac8Pool thread stack traces:Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,]Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,]Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,]