1

app context looks like

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="packagesToScan" value="com.some.domain.to.scan" /> 
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.connection.driver_class">oracle.jdbc.pool.OracleConnectionPoolDataSource</prop>
            <prop key="hibernate.connection.url">${url}</prop>
            <prop key="hibernate.connection.username">${username}</prop>
            <prop key="hibernate.connection.password">${password}</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">false</prop>
            <prop key="hibernate.cache.use_second_level_cache">${hibernate.l2_cache.enabled}</prop>
            <prop key="hibernate.cache.use_query_cache">${hibernate.l2_cache.enabled}</prop>
            <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">/settings/ehcache-hibernate-settings.xml</prop>
            <prop key="net.sf.ehcache.configurationResourceName">/settings/ehcache-hibernate-settings.xml</prop>
            <prop key="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</prop>
            <prop key="bonecp.idleMaxAge">240</prop>
            <prop key="bonecp.idleConnectionTestPeriod">60</prop>
            <prop key="bonecp.partitionCount">2</prop>
            <prop key="bonecp.acquireIncrement">5</prop>
            <prop key="bonecp.maxConnectionsPerPartition">20</prop>
            <prop key="bonecp.minConnectionsPerPartition">10</prop>
            <prop key="bonecp.statementsCacheSize">50</prop>
            <prop key="bonecp.releaseHelperThreads">2</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    <qualifier value="dbdomain"/>
</bean>

while gradle imports include latest version of bonecp-provider, bonecp and bonecp-spring along with spring 3.2.0.RELEASE and hibernate 4.1.12.Final

seemed like everything is in place but when i run the app (jetty server), it throw the following exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [app/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/connection/ConnectionProvider
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:589)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)

any help on how to correctly setup bonecp would be helpful.

UPDATE

after resolving so dependency issues with bonecp I am getting a new error as the follows:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [app/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)

a few minor changes to app context were also made but i believe they have nothing to do with the error i am getting

the changes were

<prop key="bonecp.idleMaxAge">240</prop>
<prop key="bonecp.idleConnectionTestPeriod">60</prop>

to

<prop key="bonecp.idleMaxAgeInMinutes">5</prop>
<prop key="bonecp.idleConnectionTestPeriodInMinutes">3</prop>
abroy
  • 83
  • 5

1 Answers1

1

This class has been moved to the following package:

org.hibernate.engine.jdbc.connections.spi

If you are using Maven run the following command:

mvn dependency:tree

And check how many hibernate-core versions you have in your project. You might want to exclude the hibernate dependency from the spring dependency declarations.

Your issue is caused by this BoneCP issue.

So you need to update to BoneCP 0.80.

For the XADataSource unwrapping exception you should try this solution.

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • just for clarification: hibernate.connection.provider_class has moved to org.hibernate.engine.jdbc.connections.spi? – abroy Jul 31 '14 at 14:25
  • also as for hibernate-core versions i have just the 4.1.12.Final I ran 'gradle dependencies | grep hibernate-core' got '+--- org.hibernate:hibernate-core:4.1.12.Final | \--- org.hibernate:hibernate-core:4.1.12.Final (*) +--- org.hibernate:hibernate-core:4.1.12.Final | \--- org.hibernate:hibernate-core:4.1.12.Final (*) +--- org.hibernate:hibernate-core:4.1.12.Final | \--- org.hibernate:hibernate-core:4.1.12.Final (*) +--- org.hibernate:hibernate-core:4.1.12.Final | \--- org.hibernate:hibernate-core:4.1.12.Final (*)' – abroy Jul 31 '14 at 14:29
  • @abroy Verified with the relevant documentation, BoneCP 0.8.0-RELEASE with the bonecp-provider JAR should work with Hibernate 4.1. BoneCP provider source is [here](https://github.com/wwadge/bonecp/blob/bonecp-parent-0.8.0.RELEASE/bonecp-hbnprovider/src/main/java/com/jolbox/bonecp/provider/BoneCPConnectionProvider.java) and Hibernate 4.1 ApiDocs for `ConnectionProvider` is [here](http://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.html) – vanOekel Jul 31 '14 at 15:53
  • @vanOekel It seemed I also had bonecp0.7.1.RELEASE in my dependency tree but cleared those out. now only 0.8.0, that being said when i ran my server again, this time i got a different error as the following 'Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [app/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]' – abroy Jul 31 '14 at 16:11
  • @VladMihalcea Regarding the unwrapping exception, i am not sure whether the solution you pointed to me is the actual issue, nevertheless i did change __ to ** com.some.domain.to.scan/list> ** As per the solution provided. But still getting the same error – abroy Jul 31 '14 at 18:32