web-dev-qa-db-ja.com

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

私はhibernateに移行しようとしています4.1.0.Finalspring 3.1.1.RELEASEで、以下は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" />

しかし、アプリケーションを実行しようとすると、次の例外が発生しました。

 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)

このエラーが発生する理由と修正方法を教えてください。ありがとうございます。

21
fresh_dev

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>
50
blank