您的位置:首页 > 编程语言 > Java开发

SSH:Struts has detected an unhandled exception

2016-04-21 19:46 513 查看
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.jar、apcetjweaver.jar、com.springsource.org.aopalliance-1.0.0.jar这三个包
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: