java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor
Asked Answered
S

1

21

i am trying to migrate to hibernate 4.1.0.Final with spring 3.1.1.RELEASE and following is my configuration for hibernate:

    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="${project.groupId}.domain" />


    <!-- control the behavior of Hibernate at runtime,All are optional and 
        have reasonable default values -->
    <property name="hibernateProperties">
        <value>
            <!-- hibernate.dialect: allows Hibernate to generate SQL optimized for 
                a particular relational database -->
            hibernate.dialect=org.hibernate.dialect.MySQLDialect
            hibernate.hbm2ddl.auto=create-drop
            hibernate.show_sql=false
            hibernate.jdbc.fetch_size=100
            hibernate.jdbc.batch_size=100
            hibernate.jdbc.batch_versioned_data=true
            hibernate.order_inserts=true
            hibernate.order_updates=true
            hibernate.cache.use_query_cache=false
            hibernate.cache.use_second_level_cache=false

        </value>
    </property>


</bean>

<!-- provides properties to hibernate to make it able to create session 
    factory. Hibernate uses instance of session bean of type -->
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="com.mysql.jdbc.Driver" />

    <property name="url" value="${db.url}" />

    <property name="username" value="${db.username}" />

    <property name="password" value="${db.password}" />

</bean>

<!-- responsible for creating sessionFactory opening transactions and binding 
    them to the current thread context. -->
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    <property name="nestedTransactionAllowed" value="true" />
</bean>

<!-- get exception translation from HibernateException into DataAccessException 
    hierarchy -->
<bean
    class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

but when trying to run the application, i got the following exception:

 java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)

please advise why i get this error, and how to fix it, thanks.

Sirajuddaula answered 28/3, 2012 at 13:23 Comment(1)
It sounds like you don't have the hibernate core jar on your classpath. How do you handle dependencies. Maven?Sabadell
S
51

Try using the org.springframework.orm.hibernate4.HibernateTransactionManager

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="dataSource" ref="dataSource" />
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
Swab answered 28/3, 2012 at 13:27 Comment(1)
I got the same exception for data source configuration. Used the same approach as above by changing the version of the configuration of Hibernate. org.springframework.orm.hibernate4.LocalSessionFactoryBeanRosariarosario

© 2022 - 2024 — McMap. All rights reserved.