Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor

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.

like image 734
fresh_dev Avatar asked Mar 28 '12 13:03

fresh_dev


1 Answers

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>
like image 168
blank Avatar answered Nov 02 '22 05:11

blank