我执行查询时候是使用的Query q=super.getSession().createQuery("from table");难道是由于连接没有释放导致的?
proxool版本是:0.090-CR2
cglib-nodep版本是:2.1_3
proxool.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
- <something-else-entirely>
- <proxool-config>
- <proxool>
- <alias>DBPool</alias>
- <driver-url>jdbc:mysql://localhost:3306/dbab?useUnicode=true&characterEncoding=GBK</driver-url>
- <driver-class>com.mysql.jdbc.Driver</driver-class>
- <driver-properties>
- <property name="user" value="aaa" />
- <property name="password" value="111111" />
- </driver-properties>
- <house-keeping-sleep-time>10000</house-keeping-sleep-time>
- <maximum-new-connections>20</maximum-new-connections>
- <prototype-count>5</prototype-count>
- <maximum-connection-count>100</maximum-connection-count>
- <minimum-connection-count>10</minimum-connection-count>
- <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
- </proxool>
- </proxool-config>
- </something-else-entirely>
applicationContext.xml文件
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">
- org.hibernate.dialect.MySQLDialect
- </prop>
- <prop key="hibernate.show_sql">false</prop>
- <prop key="hibernate.generate_statistics">true</prop>
- <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
- <prop key="hibernate.proxool.xml">proxool.xml</prop>
- <prop key="hibernate.proxool.pool_alias">DBPool</prop>
- <prop key="hibernate.connection.release_mode">auto</prop>
- </props>
- </property>
- </bean>
- <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close">
- <property name="driver" value="com.mysql.jdbc.Driver"/>
- <property name="driverUrl" value="jdbc:mysql://localhost:3306/dbab?useUnicode=true&characterEncoding=GBK"/>
- <property name="user" value="aaa"/>
- <property name="password" value="111111"/>
- <property name="maximumConnectionCount" value="25"/>
- <property name="minimumConnectionCount" value="5"/>
- <property name="maximumActiveTime" value="1000"/>
- <property name="delegateProperties" value="user=aaa,password=111111"/>
- </bean>
通过加载log4j日志文件发现问题的根本
报错的部分代码
- 2008-09-08 13:54:03,812 WARN [net.sf.ehcache.config.Configurator] - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/KYPro2/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
- 2008-09-08 13:54:05,203 ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: com.ky.hibernate.vo.Userdata
- java.lang.ExceptionInInitializerError
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:585)
- at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:586)
- at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:579)
ehcache-failsafe.xml发现这个文件确实存在,
试着在WEB-INF建立文件ehcache.xml配置文件一样报错,又以为是ehcache版本的问题下载了一个1.2.4版本的jar包结果还是报错.
基本上可以肯定应该不是ehcache包的问题了,接着看下面另外一句错误 CGLIB Enhancement failed 百度了一下发现整个工程中存在两个cglib包一个是hibernate自带的cglib-2.2.jar包一个是spring自带的cglib-nodep.jar包去掉其中的hibernate自带的那个包,还有就是spring自带的asm-2.2.2.jar asm-commons-2.2.2.jar asm-util-2.2.2.jar 与Hibernate自带的asm.jar asm-attrs.jar 其中asm-2.2.2.jar与asm.jar存在类上的冲突!!去掉asm-attrs.jar包即可.
由于这两个包所引发的报错还可能是
- 2008-09-08 15:14:47,609 ERROR [org.springframework.web.struts.ContextLoaderPlugIn] - Context initialization failed
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/BlockingQueue
- java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/BlockingQueue
- at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:418)
- at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:334)
- at net.sf.ehcache.CacheManager.configure(CacheManager.java:306)
- at net.sf.ehcache.CacheManager.init(CacheManager.java:226)
asm-attrs.jar
cglib-2.1.3.jar
加入
cglib-nodep-2.1_3.jar
附带下载地址:http://sourceforge.net/project/showfiles.php?group_id=56933&package_id=98218&release_id=601998