Search code examples
javaspringhibernatespring-mvcspring-orm

hibernate3.LocalDataSourceConnectionProvider cannot be cast to ConnectionProvider


2.4release , hibernate 3.3.2ga . while creating sessionfactory. I'm getting following error. Please provide me a solution

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="erpUSDataSource" />

            <property name="annotatedClasses">
                <list>
                    <value>com.bean.OrderDetailsVO</value>
                    <value>com.bean.OrderVO</value>
                </list>

            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <!--  <prop key="hibernate.hbm2ddl.auto">update</prop> -->
                    <!-- <prop key="hibernate.use_outer_join">false</prop>
                    <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
                    <prop key="hibernate.hibernate.cache.use_query_cache">true</prop> -->
                </props>
            </property>
     </bean>
     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"/>
     </bean>

Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:192) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:114) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] ... 90 more Caused by: java.lang.ClassCastException: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:189) [hibernate-core-4.2.0.Final-redhat-1.jar:4.2.0.Final-redhat-1] ... 94 more


Solution

  • I have added Hibernate jars 4.0.1.Final including Hibernate Entitymanagaer, Hibernate-commons annotation, antlr 2.x,antlr-runtime2.x ..

    My guess I got the problem due to not including above jars. I have added above jars my problem got resolved

    com.bean.OrderDetailsVO com.bean.OrderVO org.hibernate.dialect.SQLServer2008Dialect true update</prop> --> false</prop> net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> true</prop> -->