SSH:Struts has detected an unhandled exception
2016-04-21 19:46
513 查看
SSH框架版本struts2.3+hibernate4.3+spring4.0
<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这三个包
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这三个包
相关文章推荐
- 快速构建Spring boot项目(功能是检测访问页面的设备)
- Struts2中namespace的用法
- struts --interceptor
- 如何在Eclipse中查看JDK类库的源代码 【转】
- Eclipse将输出结果保存到文件中
- Java urlrewrite+Maven 简单使用
- Java Calendar 基础详解实例
- struts--Action解读
- HashMap内部实现原理
- java并发之Lock与synchronized的区别
- Java加密技术(一)——BASE64与单向加密算法MD5&SHA&MAC
- Spark-submit 时出现java.lang.ClassNotFoundException
- java容器学习
- java 链表 树
- java并发之Lock
- Java读取properties文件中文乱码问题解决
- struts2动态方法调用
- java发送get/post请求
- 20160421javaweb之上传下载小案例---网盘
- LeetCode145 Binary Tree Postorder Traversal(迭代实现) Java