我是靠谱客的博主 自觉月亮,最近开发中收集的这篇文章主要介绍SSH:Struts has detected an unhandled exceptionStruts has detected an unhandled exception: Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction d,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

SSH框架版本struts2.3+hibernate4.3+spring4.0

Struts has detected an unhandled exception:

Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

解决方法:

<1>在application-context.xml中添加事务处理

      <!-- 配置事务管理器-->

      <bean id="transactionManager"

           class="org.springframework.orm.hibernate3.HibernateTransactionManager">

           <property name="sessionFactory" ref="sessionFactory"></property>

      </bean>

      <!-- 配置事务的传播特性-->

      <tx:advice id="txAdvice" transaction-manager="transactionManager">

           <tx:attributes>

                 <tx:method name="add*" propagation="REQUIRED"/>

                 <tx:method name="delete*"   propagation="REQUIRED"/>

                 <tx:method name="update*"  propagation="REQUIRED"/>

                 <tx:method name="*" read-only="true" />

           </tx:attributes>

      </tx:advice>

      <aop:config>

           <aop:pointcut id="managersMethod"

                 expression="execution( *com.love.lifang.struts2spring.dao.impl.*Impl.*(..))" />

           <aop:advisor advice-ref="txAdvice" pointcut-ref="managersMethod"/>

      </aop:config>

<2>如果还出现异常严重:

Exceptionsending context destroyed event to listener instance of classorg.springframework.web.context.ContextLoaderListener

java.lang.IllegalStateException: BeanFactory not initializedor already closed - call 'refresh' before accessing beans via theApplicationContext

Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

这是由于缺少必要的jar包引起的,还需要添加

aspcetjrt.jarapcetjweaver.jarcom.springsource.org.aopalliance-1.0.0.jar这三个包


最后

以上就是自觉月亮为你收集整理的SSH:Struts has detected an unhandled exceptionStruts has detected an unhandled exception: Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction d的全部内容,希望文章能够帮你解决SSH:Struts has detected an unhandled exceptionStruts has detected an unhandled exception: Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction d所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部