Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can not run C3P0ConnectionProvider

my 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>

my library:

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

and my Error:

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)
like image 594
Max Usanin Avatar asked Apr 29 '13 11:04

Max Usanin


1 Answers

I had the same problem, hope my solution work for you too:

1: since you're using hibernate-c3p0-4.1.10.Final.jar, your provider_class should be:

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

from Error Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.connection.C3P0ConnectionProvider]

Also, make sure you include both c3p0-0.9.1.jar and hibernate-c3p0-4.2.1.Final.jar (should be in the same folder "\hibernate-release-4.2.1.Final\lib\optional\c3p0\" )

I ended up downloading the latest Hibernate release (4.2.1) here http://planet.jboss.org/post/hibernate_orm_4_2_1_final_and_4_1_12_final_released

and updating all the hibernate related jars in my project to get it to work properly, since the download link in eclipse only has the 3.6.0 Final version (JBoss Hibernate - http://download.jboss.org/jbosstools/updates/stable/)

like image 185
user1784377 Avatar answered Oct 11 '22 08:10

user1784377