web-dev-qa-db-ja.com

C3P0ConnectionProviderを実行できません

私のhibernate.cfg.xml

<property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="show_sql">true</property>
        <property name="connection.url">jdbc:postgresql://localhost:5432/pirates</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password">mmm888</property>

        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="show_sql">false</property>
        <property name="hbm2ddl.auto">update</property>
        <property name="current_session_context_class">thread</property>

        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> 
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">200</property>
        <property name="hibernate.c3p0.timeout">300</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>
        <property name="hibernate.generate_statistics">true</property>

私の図書館:

hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.10.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-validator-4.2.0.Final.jar
jbossjta-4.16.4.Final.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
openjdk-6-b14.jar
validation-api-1.0.0.GA.jar
hibernate-c3p0-4.1.10.Final.jar

と私のエラー:

29.04.2013 14:02:43 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName
WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead.
29.04.2013 14:02:43 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
Failed to create sessionFactory object.org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
29.04.2013 14:02:43 org.Apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [request] in context with path [/Pirates] threw exception [Servlet execution threw an exception] with root cause
Java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.Java:99)
    at Java.lang.ClassLoader.loadClass(Unknown Source)
    at Java.lang.ClassLoader.loadClass(Unknown Source)
    at Java.lang.Class.forName0(Native Method)
    at Java.lang.Class.forName(Unknown Source)
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.Java:138)
    at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.Java:189)
    at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.Java:114)
    at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.Java:54)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.Java:69)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.Java:176)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.Java:150)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.Java:131)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.Java:223)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.Java:89)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.Java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.Java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.Java:131)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.Java:71)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.Java:2277)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.Java:2273)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.Java:1742)
    at hibernate.Hibernate.initFactory(Hibernate.Java:39)
    at hibernate.Hibernate.getFactory(Hibernate.Java:23)
    at hibernate.Hibernate.openSession(Hibernate.Java:49)
    at action.Action.init(Action.Java:96)
    at action.Action.performAction(Action.Java:65)
    at servlets.RequestHandlerServlet.service(RequestHandlerServlet.Java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet.Java:722)
    at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:305)
    at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
    at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:225)
    at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:169)
    at org.Apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.Java:472)
    at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:168)
    at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:98)
    at org.Apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.Java:927)
    at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:118)
    at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:407)
    at org.Apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.Java:999)
    at org.Apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.Java:565)
    at org.Apache.Tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.Java:307)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at Java.lang.Thread.run(Unknown Source)
11
Max Usanin

私も同じ問題を抱えていました。私の解決策があなたにも役立つことを願っています:

1:hibernate-c3p0-4.1.10.Final.jarを使用しているため、provider_classは次のようになります。

<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

from エラーの原因:org.hibernate.HibernateException:接続プロバイダー[org.connection.C3P0ConnectionProvider]をインスタンス化できませんでした

また、c3p0-0.9.1.jarとhibernate-c3p0-4.2.1.Final.jarの両方が含まれていることを確認してください(同じフォルダー "\ hibernate-release-4.2.1.Final\lib\optional\c3p0にある必要があります)\")

ここで最新のHibernateリリース(4.2.1)をダウンロードすることになりました http://planet.jboss.org/post/hibernate_orm_4_2_1_final_and_4_1_12_final_released

eclipseのダウンロードリンクには3.6.0の最終バージョン(JBoss Hibernate -- http://download.jboss.org/jbosstools)しかないため、プロジェクト内のすべてのHibernate関連のjarを更新して正しく機能させるようにします。/updates/stable /

11
user1784377

c3p0

Hibernate配布libディレクトリにある上記のliraryjarファイルを追加します

5
Fred Ondieki