2 Replies Latest reply on Feb 28, 2012 9:31 AM by smarlow

    What to replace c3p0 connection provider in hibernate 4

    coolsky

      I am using Jboss 7 which is using hibernate 4. When I try to deploy my project which was using hibernate 3 with c3p0 connection provider, I found there is such error information below:

       

      14:44:17,977 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-7) HHH000208: org.hibernate.con
      nection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider w
      ill be used instead.
      
      14:44:17,977 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-7) HHH000130: Instantiating exp
      licit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
      14:44:17,987 INFO  [stdout] (MSC service thread 1-7) org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ser
      vice.jdbc.connections.spi.ConnectionProvider]
      14:44:17,987 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceReg
      istryImpl.java:187)
      14:44:17,987 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServic
      eRegistryImpl.java:150)
      14:44:17,987 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegist
      ryImpl.java:131)
      14:44:17,987 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesI
      mpl.java:234)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:91)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardService
      RegistryImpl.java:75)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServic
      eRegistryImpl.java:159)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegist
      ryImpl.java:131)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
      14:44:17,997 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
      14:44:18,007 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
      14:44:18,007 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
      14:44:18,007 INFO  [stdout] (MSC service thread 1-7)    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
      
      
      

       

      My question is is there any connecton provided recommanded in hibernate 4 to replace the old c3p0 connection provider. Can anyone help me resolve this issue?

        • 1. Re: What to replace c3p0 connection provider in hibernate 4
          coolsky

          I put c3p0-0.9.1.jar and hibernate-c3p0-4.0.1.Final.jar which should have org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider class in my classpath but still have the same error.

           


          Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.service.jdbc.connections.internal.C3P0Connection
          Provider]
                  at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiat
          or.java:190) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
                  at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:112) [hibernat
          e-core-4.0.1.Final.jar:4.0.1.Final]
                  at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54) [hibernate
          -core-4.0.1.Final.jar:4.0.1.Final]
                  at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) [hibernate-core-4.0.1.Final
          .jar:4.0.1.Final]
                  at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:177) [hibernate-core-4.0.1.Final.
          jar:4.0.1.Final]
                  ... 51 more
          Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.service.jdbc.connections.internal.C3P0Con
          nectionProvider]
                  at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141) [hibernate-core-4.0.1.Fina
          l.jar:4.0.1.Final]
                  at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiat
          or.java:187) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
                  ... 55 more
          Caused by: 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) [hibernate-core-4.0.1.Final.
          jar:4.0.1.Final]
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [rt.jar:1.6.0_07]
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [rt.jar:1.6.0_07]
                  at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138) [hibernate-core-4.0.1.Fina

          • 2. Re: What to replace c3p0 connection provider in hibernate 4
            smarlow

            Is your application using the JPA interfaces or the Hibernate native apis?  Do you have a persistence.xml or configuration file that you can show here.

             

            AS7 has a managed connection pool, that is one option.  http://docs.jboss.org/hibernate/core/4.0/quickstart/en-US/html_single/ mentions C3P0 but we didn't include that in the AS7 distribution.  After answering the above questions, we can give guidance on how you can add C3P0.

             

            Scott