-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon Apr 11, 2016 3:27 am 
Newbie

Joined: Fri Dec 08, 2006 5:44 pm
Posts: 13
Greetings,

I am attempting to go from Hibernate 3 to 5.1.0. When running my program I get:

Code:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
   at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:832)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   at sun.rmi.transport.Transport$1.run(Transport.java:200)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at sun.rmi.transport.Transport$1.run(Transport.java:197)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
   at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
   at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
   at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$95(TCPTransport.java:683)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
   at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
   at java.lang.Thread.run(Thread.java:745)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.connection.C3P0ConnectionProvider]
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:194)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:139)
   at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:111)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:157)
   at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:41)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:151)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:140)
   ... 115 more
   at com.arahant.utils.ArahantSession.<clinit>(ArahantSession.java:62)
Caused by: java.lang.ClassCastException: org.hibernate.connection.C3P0ConnectionProvider cannot be cast to org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
   at java.lang.Class.forName0(Native Method)
   at org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:191)
   at java.lang.Class.forName(Class.java:348)


My config looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <!--   Set the machine, user & password here  -->
    <property name="hibernate.connection.url">jdbc:postgresql://localhost/waytogo</property>
    <property name="hibernate.connection.username">postgres</property>
    <property name="hibernate.connection.password">postgres</property>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL92Dialect</property>

    <!--  DO NOT CHANGE BELOW THIS LINE!   -->
    <property name="hibernate.jdbc.batch_size">50</property>
    <property name="hibernate.cache.use_second_level_cache">true</property>
    <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.bytecode.use_reflection_optimizer">true</property>
    <property name="hibernate.connection.release_mode">on_close</property>
    <property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>
    <!-- configuration pool via c3p0  -->
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.idle_test_period">100</property>
    <property name="hibernate.c3p0.max_size">90</property>
    <property name="hibernate.c3p0.max_statements">0</property>
    <property name="hibernate.c3p0.min_size">1</property>
    <property name="hibernate.c3p0.timeout">0</property>
    <property name="hibernate.c3p0.testConnectionOnCheckin">true</property>
    <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
    <property name="hibernate.c3p0.unreturnedConnectionTimeout">300000</property>
    <property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>
    <property name="hibernate.c3p0.com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator">com.mchange.v2.c3p0.management.NullManagementCoordinator</property>
  </session-factory>
</hibernate-configuration>


Any help would sure be appreciated.

Blake McBride


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon Apr 11, 2016 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The reason why you get an exception is because the package for C3P0ConnectionProvider has changed.

You need to remove this property:

Code:
<property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>


Hibernate defaults to C3P0ConnectionProvider if you supply at least one "hibernate.c3p0" configuration property.


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon Apr 11, 2016 8:28 am 
Newbie

Joined: Fri Dec 08, 2006 5:44 pm
Posts: 13
Okay. I took that line out and I am getting the same error. Not sure what to do. Thanks for the help!


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon Apr 11, 2016 9:06 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Check the dependencies and make sure that you don;t have both Hibernate 3 and Hibernate 4 jars on the classpath.


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon Apr 11, 2016 9:14 pm 
Newbie

Joined: Fri Dec 08, 2006 5:44 pm
Posts: 13
I made some changes. This is the startup error I get now:

Code:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:140)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:155)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:151)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:140)
   at com.arahant.utils.ArahantSession.<clinit>(ArahantSession.java:62)
   at java.lang.Class.forName0(Native Method)
.....
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:140)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:155)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:151)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:140)
   at com.arahant.utils.ArahantSession.<clinit>(ArahantSession.java:62)
.....
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more
[ERROR] [utils.HibernateUtil      ] - org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:140)
   at com.arahant.utils.HibernateSessionUtil.<init>(HibernateSessionUtil.java:155)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:151)
   at com.arahant.utils.ArahantSession.openHSU(ArahantSession.java:140)
   at com.arahant.utils.ArahantSession.<clinit>(ArahantSession.java:62)
.....
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more
....
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   ... 94 more
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more
....
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   ... 94 more
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more
....
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
   at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:663)
   at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
   at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
   at com.arahant.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:71)
   ... 94 more
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:84)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:29)
   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
   ... 102 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
   at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)
   at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:71)
   ... 105 more



Here are all of my jars:

Code:
abcl.jar
ant-1.6.5.jar
antlr-2.7.7.jar
asm-4.0.jar
asm-analysis-4.0.jar
asm-commons-4.0.jar
asm-tree-4.0.jar
asm-util-4.0.jar
c3p0-0.9.2.1.jar
cglib-2.2.jar
checkstyle-all.jar
ClassEncryptor.jar
classmate-1.3.0.jar
cleanimports.jar
commons-beanutils-1.8.3.jar
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-discovery-0.4.jar
commons-fileupload-1.2.2.jar
commons-httpclient-3.0.1.jar
commons-io-2.0.1.jar
commons-logging-1.1.1.jar
concurrent-1.3.2.jar
connector.jar
dom4j-1.6.1.jar
ehcache-2.10.1.jar
ganymed-ssh2-build251beta1.jar
geronimo-jta_1.1_spec-1.1.1.jar
groovy-2.3.7.jar
gwt-servlet.jar
hibernate-c3p0-5.1.0.Final.jar
hibernate-commons-annotations-5.0.1.Final.jar
hibernate-core-5.1.0.Final.jar
hibernate-ehcache-5.1.0.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
iText-5.0.5.jar
jaas.jar
jacc-1_0-fr.jar
jackson-annotations-2.5.4.jar
jackson-core-2.5.4.jar
jackson-databind-2.5.4.jar
jandex-2.0.0.Final.jar
jasperreports-4.0.1.jar
javassist-3.20.0-GA.jar
jaxen-1.1-beta-7.jar
jaxrpc.jar
jbosscache-core-3.2.1.GA.jar
jboss-logging-3.3.0.Final.jar
jce.jar
jdbc2_0-stdext.jar
jess.jar
jgroups-2.2.8.jar
jta-1.1.jar
jtds-1.2.5.jar
junit-4.11.jar
log4j-1.2.16.jar
mail.jar
mchange-commons-java-0.2.3.4.jar
ojdbc14_g.jar
ojdbc14.jar
oscache-2.1.jar
pdfbox-2.0.0-20160304.180026-2013.jar
pdfbox-app-2.0.0-20160304.180235-1980.jar
postgresql-9.3-1102.jdbc3.jar
proxool-0.8.3.jar
resolver.jar
saaj-api.jar
saaj-impl.jar
serializer.jar
slf4j-api-1.7.7.jar
sqljdbc.jar
swarmcache-1.0rc2.jar
syndiag2.jar
thread-scope-1.3.jar
toolbox.jar
versioncheck.jar
xercesImpl-2.11.0.jar
xml-apis.jar



Here is what my config looks like now:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <!--   Set the machine, user & password here  -->
    <property name="hibernate.connection.url">jdbc:postgresql://localhost/waytogo</property>
    <property name="hibernate.connection.username">postgres</property>
    <property name="hibernate.connection.password">postgres</property>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL92Dialect</property>

    <property name="hibernate.jdbc.batch_size">50</property>
    <property name="hibernate.cache.use_second_level_cache">true</property>
    <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.bytecode.use_reflection_optimizer">true</property>
    <property name="hibernate.connection.release_mode">on_close</property>
    <!-- configuration pool via c3p0  -->
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.idle_test_period">100</property>
    <property name="hibernate.c3p0.max_size">90</property>
    <property name="hibernate.c3p0.max_statements">0</property>
    <property name="hibernate.c3p0.min_size">1</property>
    <property name="hibernate.c3p0.timeout">0</property>
    <property name="hibernate.c3p0.testConnectionOnCheckin">true</property>
    <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
    <property name="hibernate.c3p0.unreturnedConnectionTimeout">300000</property>
    <property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>
    <property name="hibernate.c3p0.com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator">com.mchange.v2.c3p0.management.NullManagementCoordinator</property>
  </session-factory>
</hibernate-configuration>


I really appreciate the help. Kind of lost.

Thanks!

Blake


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Tue Apr 12, 2016 1:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
That's strange indeed. You have the ehcache Hibernate dependency and the region factory set, so I'm not sure why it fails for you.


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Tue Apr 12, 2016 8:22 am 
Newbie

Joined: Fri Dec 08, 2006 5:44 pm
Posts: 13
Thank you. That is very helpful. I now know I have the right jars, and my config file is reasonable. I'll start simplifying my code (cutting out code) until the problem goes away. I'll know what it is then.

Thanks.


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Tue Apr 12, 2016 9:06 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
If you find the culprit, it' a good idea to post the solution here as others might find it useful too.


Top
 Profile  
 
 Post subject: Re: C3P0ConnectionProvider cannot be cast to org.hibernate.engin
PostPosted: Mon May 02, 2016 7:50 pm 
Newbie

Joined: Fri Dec 08, 2006 5:44 pm
Posts: 13
I found the problem. Although I had the right jars for the development process, some of the jars were missing in the deployment process. So, the error was caused by the following missing jars:

hibernate-c3p0-5.1.0.Final.jar
hibernate-ehcache-5.1.0.Final.jar
mchange-commons-java-0.2.3.4.jar


It boots now without crashing.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.