使用 C3P0、OneJar 和 MySQL C3P0 设置时出现死锁如下
pooledDataSource=new ComboPooledDataSource();
set database properies ie userName password driver etc
pooledDataSource.setMaxPoolSize(100);
pooledDataSource.setMinPoolSize(10);
pooledDataSource.setInitialPoolSize(10);
pooledDataSource.setAcquireIncrement(4);
pooledDataSource.setIdleConnectionTestPeriod(900);
pooledDataSource.setTestConnectionOnCheckin(true);
pooledDataSource.setMaxIdleTimeExcessConnections(300);
pooledDataSource.setNumHelperThreads(6);
pooledDataSource.setMaxAdministrativeTaskTime(60);
pooledDataSource.setUnreturnedConnectionTimeout(120);
pooledDataSource.setDebugUnreturnedConnectionStackTraces(true);
**Thread Dump is as follows**
Found one Java-level deadlock:
=============================
"com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3":
waiting to lock monitor 0x00007f443abe32a0 (object 0x00000000c6071690, a com.simontuffs.onejar.JarClassLoader),
which is held by "main"
"main":
waiting to lock monitor 0x00007f443abe2b68 (object 0x00000000c615e950, a com.simontuffs.onejar.JarClassLoader$1),
which is held by "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3"
Java stack information for the threads listed above:
===================================================
"com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3":
at java.lang.ClassLoader.loadClass(ClassLoader.java:403)
- waiting to lock <0x00000000c6071690> (a com.simontuffs.onejar.JarClassLoader)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
- locked <0x00000000c615e950> (a com.simontuffs.onejar.JarClassLoader$1)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.simontuffs.onejar.JarClassLoader$1.loadClass(JarClassLoader.java:296)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
- locked <0x00000000c615e950> (a com.simontuffs.onejar.JarClassLoader$1)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.simontuffs.onejar.JarClassLoader$1.loadClass(JarClassLoader.java:296)
at com.mysql.jdbc.DatabaseMetaData$9.forEach(DatabaseMetaData.java:5276)
at com.mysql.jdbc.DatabaseMetaData$9.forEach(DatabaseMetaData.java:5239)
at com.mysql.jdbc.IterateBlock.doForAll(IterateBlock.java:50)
at com.mysql.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:5238)
at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnectionNoQuery(DefaultConnectionTester.java:185)
at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:62)
at com.mchange.v2.c3p0.AbstractConnectionTester.activeCheckConnection(AbstractConnectionTester.java:67)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:368)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishResourceOnCheckin(C3P0PooledConnectionPool.java:301)
at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckin(BasicResourcePool.java:1606)
at com.mchange.v2.resourcepool.BasicResourcePool.access$200(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask.run(BasicResourcePool.java:1228)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
"main":
at java.lang.ClassLoader.loadClass(ClassLoader.java:403)
- waiting to lock <0x00000000c615e950> (a com.simontuffs.onejar.JarClassLoader$1)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.simontuffs.onejar.JarClassLoader$1.loadClass(JarClassLoader.java:296)
at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:642)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
- locked <0x00000000c6071690> (a com.simontuffs.onejar.JarClassLoader)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.hibernate.cfg.SettingsFactory.createBatcherFactory(SettingsFactory.java:443)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:195)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
- locked <0x00000000fa3ce208> (a java.util.concurrent.ConcurrentHashMap)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:591)
- locked <0x00000000fa3ce258> (a java.util.concurrent.ConcurrentHashMap)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
- locked <0x00000000fa3ce358> (a java.lang.Object)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.goldensource.activegateway.backoffice.launcher.BackOfficeJobLauncher.sendNotification(BackOfficeJobLauncher.java:464)
at com.goldensource.activegateway.backoffice.launcher.BackOfficeJobLauncher.main(BackOfficeJobLauncher.java:186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Found 1 deadlock.
但是当我使用 jtds 连接 SQL 数据库时,一切正常吗?谁能告诉我出了什么问题?