当前位置: 代码迷 >> Java Web开发 >> 集成Shiro 一直出错 提示org.hibernate.HibernateException: No Session found for current th
  详细解决方案

集成Shiro 一直出错 提示org.hibernate.HibernateException: No Session found for current th

热度:472   发布时间:2016-04-16 21:56:52.0
集成Shiro 一直报错 提示org.hibernate.HibernateException: No Session found for current th
 版本   Spring  4.0.6.RELEASE
        Hibernate  4.3.6.Final
        Shiro     1.2.3
        Ehcache    2.5.1


异常信息:

严重: Servlet.service() for servlet [springmvc] in context with path [/test] threw exception [org.hibernate.HibernateException: No Session found for current thread] with root cause
org.hibernate.HibernateException: No Session found for current thread
    at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106)
    at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
    at com.common.base.BaseDao.getsession(BaseDao.java:25)
    at com.common.base.BaseDao.createQuery(BaseDao.java:55)
    at com.common.base.BaseDao.findByHQL(BaseDao.java:47)
    at com.modelus.service.imp.UserServiceImp.account(UserServiceImp.java:39)
    at com.modelus.service.imp.UserServiceImp$$FastClassBySpringCGLIB$$f3b65bb1.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
    at com.modelus.service.imp.UserServiceImp$$EnhancerBySpringCGLIB$$734b389d.account(<generated>)
    at com.common.shiro.AuthorizingRealmImp.doGetAuthorizationInfo(AuthorizingRealmImp.java:32)
    at org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:341)
    at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:461)
    at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:457)
    at org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
    at org.apache.shiro.authz.ModularRealmAuthorizer.isPermittedAll(ModularRealmAuthorizer.java:291)
    at org.apache.shiro.mgt.AuthorizingSecurityManager.isPermittedAll(AuthorizingSecurityManager.java:129)
    at org.apache.shiro.subject.support.DelegatingSubject.isPermittedAll(DelegatingSubject.java:182)
    at org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter.isAccessAllowed(PermissionsAuthorizationFilter.java:49)
    at org.apache.shiro.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:162)
    at org.apache.shiro.web.filter.PathMatchingFilter.isFilterChainContinued(PathMatchingFilter.java:203)
    at org.apache.shiro.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:178)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:131)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
  相关解决方案