Could not obtain transaction-synchronized Session for current thread解决方法
2017-11-07 12:36
1476 查看
调用session factory 时抛出的异常
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current threadnull
2017-11-06 20:19:23.342 ERROR 4292 --- [0.1-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at com.hwj.web.IndexController.getId(IndexController.java:79)
at com.hwj.web.IndexController$$FastClassBySpringCGLIB$$e54c6cb4.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.hwj.aspect.HttpAspect.daRound(HttpAspect.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.hwj.web.IndexController$$EnhancerBySpringCGLIB$$bbeabbb9.getId(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
解决方法:
1. 检查Session Factory是否开启事物注解(如没有,在配置中开启事物注解) 传送门
2.在impl层注入@Transactional
相关文章推荐
- Could not obtain transaction-synchronized Session for current thread 错误的解决方法!
- Spring-hibernate开发时遇到 Could not obtain transaction-synchronized Session for current thread的问题解决
- spring+Hibernate5的Could not obtain transaction-synchronized Session for current thread解决
- Could not obtain transaction-synchronized Session for current thread
- Hibernate4 提示Could not obtain transaction-synchronized Session for current thread
- 【Hibernate】Could not obtain transaction-synchronized Session for current thread
- hibernate之事务-Could not obtain transaction-synchronized Session for current thread
- SpringMVC中Could not obtain transaction-synchronized Session for current thread的解决方案
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
- 解决异常:org. 8af0 hibernate.HibernateException: Could not obtain transaction-synchronized Session for current
- Could not obtain transaction-synchronized Session for current thread
- ssh整合 出现Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- 关于Hibernate Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread 解决方案
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread