解决Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundEr

来源:互联网 发布:中介管理系统源码 编辑:程序博客网 时间:2024/05/16 03:02

我使用的是5.2.8的hibernate的jar包,运行的时候却报错Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext

原因是配置文件中

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

用的是hibernate4

解决方法:1:将换成hibernate-core-5.2.8.Final.jar换成hibernate-core-4.2.4.Final.jar

自己运行能够成功解决问题

              2:class="org.springframework.orm.hibernate5.HibernateTransactionManager"

没有解决bug,但理论上应该是可以的


注意:在出现此种错误时,会在错误界面的最下方显示如下内容:

You are seeing this page because development mode is enabled.

To disable this mode, set: 
struts.devMode=false
in your WEB-INF/classes/struts.properties file.

很多配置问题都会出现这一错误,因此可能会误导,要非常注意,一般情况下不要那么设置。

0 0