配置proxool不能实例化ProxoolConnectionProvider问题的解决

配置proxool,加载了proxool的包,一直报错,看错误提示,说不能实例化ProxoolConnectionProvider,查hibernate核心包,里面connection里确实没有这个东东,后来才知道要加载一个hibernate-proxool包才行,可所有配置的教程都没提过,是不是这是该默认知道的东西,我了解的东西太少了?

在maven里加入这个包的最新版本4.1,却发现还是不行,解包一看,4.1里面ProxoolConnectionProvider的pakage路径换了,再晕,这也没事换换啊。因为前面的东西有基于hibernate 3.5.1的,干脆换成3.5.1版本,OK了。

现在将我的spring+struts+jpa(hibernate)+proxool的配置文件贴出来,希望对大家有用,不过目前我的配置会报一个jndi找不到路径名的警告,但不影响运行,这个问题还待解决,见我博客上一篇文章,求解答啊:http://blog.csdn.net/yyzhq/article/details/7484620

WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="struts2springjpa" version="2.5">
<display-name>Struts 2 Spring JPA Example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

WEB-INF/classes/applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="
http://www.springframework.org/schema/beans"
xmlns:context="
http://www.springframework.org/schema/context"
xmlns:tx="
http://www.springframework.org/schema/tx"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="
http://www.springframework.org/schema/aop"
xmlns:jdbc="
http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- scans the classpath for annotated components (including @Repostory
and @Service that will be auto-registered as Spring beans -->
<context:component-scan base-package="com.yesrj.ppm.global.system" />

<!-- methods or classes needing to run in a complete transaction will
be annotated with Transactional -->
<tx:annotation-driven />

<!-- Creates a data source that can provide a connection to in-memory embedded database populated
with test data
see:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch12s08.html -->

<!-- This will ensure that hibernate or jpa exceptions are automatically translated into
Spring's generic DataAccessException hierarchy for those classes annotated with Repository
For example see PersonDaoJpa-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- JPA Entity Manager Factory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="META-INF/persistence.xml" />
<property name="persistenceUnitName" value="springJpaPersistenceUnit" />
</bean>

<!-- bean post-processor for JPA annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />


<!-- Transaction Config -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- use declarative transaction management -->
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

WEB-INF/classes/struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"
http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.devMode" value="true" />

<package name="system" extends="struts-default">

<interceptors>
<interceptor-stack name="appDefaultStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="appDefaultStack" />

<global-results>
<result name="error">/error.jsp</result>
</global-results>


<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="error" />
</global-exception-mappings>

<action name="personFinder"
class="com.yesrj.plm2.global.system.action.PersonFinder" method="execute">
<result name="success">/personinfo.jsp</result>
</action>

<action name="allPersonsFinder"
class="com.yesrj.plm2.global.system.action.AllPersonsFinder" method="execute">

<result name="success">/personsinfo.jsp</result>

</action>

<action name="*PersonUpdate"
class="com.yesrj.plm2.global.system.action.PersonUpdater" method="{1}">

<result name="input">/inputpersonupdate.jsp</result>
<result name="success">/personupdated.jsp</result>

</action>

<action name="personDelete"
class="com.yesrj.plm2.global.system.action.PersonDeleter" method="execute">

<result name="success">/persondeleted.jsp</result>

</action>

<action name="*PersonSave" class="com.yesrj.plm2.global.system.action.PersonSaver"
method="{1}">

<result name="input">/inputpersonsave.jsp</result>
<result name="success">/personsaved.jsp</result>

</action>

</package>

</struts>

META-INF/persistence.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="
http://java.sun.com/xml/ns/persistence"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistencehttp://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- this persistence unit is for the web application -->
<persistence-unit name="springJpaPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:comp/env/jdbc/yespm</non-jta-data-source>

<class>com.yesrj.ppm.global.system.model.Person</class>

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true" />

<property name="hibernate.connection.provider_class" value="org.hibernate.connection.ProxoolConnectionProvider"/>
<property name="hibernate.proxool.pool_alias" value="MysqlPool"/>
<property name="hibernate.proxool.xml" value="proxool.xml"/>
</properties>
</persistence-unit>

</persistence>

WEB-INF/classes/proxool.xml

<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
<proxool>
<alias>MysqlPool</alias>

<driver-url>jdbc:mysql://localhost:3306/yespm</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>

<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>

你可能感兴趣的:(Connection)