用spring+struts2+hibernate做了一个项目,一切正常,只是睡一晚上起来再打开就出现以下异常,然后刷新一下就又没事了。什么原因?望大位大虾指点迷津。
exception javax.servlet.ServletException: org.springframework.transaction.CannotCreateTransactionException:
Could not open Hibernate Session for transaction;
nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
exception javax.servlet.ServletException: org.springframework.transaction.CannotCreateTransactionException:
Could not open Hibernate Session for transaction;
nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
以前有过将过滤器配置到web.xml最后,
第一次不能过滤但再刷新就过滤的情况
你是不是也有类似的情况 配置文件内容放的有问题?
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" isolation="REPEATABLE_READ"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txnServices"
expression="execution(* com.hongxing.shop.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="txnServices" />
</aop:config>
下面是异常:
Last packet sent to the server was 0 ms ago.
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure