0
我正在嘗試將項目從grails 2.5.4升級到3.1.8,現在我陷入了以下錯誤。從Grails 2.5.4升級到3.1.8,GORM錯誤
org.springframework.dao.DataAccessResourceFailureException: Could not obtain current Hibernate Session; nested exception is org.hibernate.HibernateException: No Session found for current thread
org.grails.orm.hibernate.GrailsHibernateTemplate.getSession(GrailsHibernateTemplate.java:227)
org.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:183)
org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:140)
org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:110)
org.grails.orm.hibernate.AbstractHibernateGormStaticApi.findWhere(AbstractHibernateGormStaticApi.groovy:335)
org.grails.datastore.gorm.GormStaticApi.findWhere(GormStaticApi.groovy:658)
org.grails.datastore.gorm.GormEntity$Trait$Helper.findWhere(GormEntity.groovy:841)
org.grails.datastore.gorm.GormEntity$Trait$Helper$findWhere$4.call(Unknown Source)
com.etherapia.portal.security.User.findWhere(User.groovy)
com.etherapia.portal.security.User$findWhere$0.call(Unknown Source)
grails.plugin.springsecurity.userdetails.GormUserDetailsService.$tt__loadUserByUsername(GormUserDetailsService.groovy:60)
grails.plugin.springsecurity.userdetails.GormUserDetailsService$_loadUserByUsername_closure1.doCall(GormUserDetailsService.groovy)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
groovy.lang.Closure.call(Closure.java:426)
groovy.lang.Closure.call(Closure.java:442)
grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
grails.plugin.springsecurity.userdetails.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy)
grails.plugin.springsecurity.userdetails.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:71)
org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices.processAutoLoginCookie(TokenBasedRememberMeServices.java:123)
org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.autoLogin(AbstractRememberMeServices.java:113)
org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:97)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.groovy:58)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:75)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
org.hibernate.HibernateException: No Session found for current thread
org.grails.orm.hibernate.GrailsSessionContext.currentSession(GrailsSessionContext.java:117)
org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
org.grails.orm.hibernate.SessionFactoryProxy.getCurrentSession(SessionFactoryProxy.java:148)
org.grails.orm.hibernate.GrailsHibernateTemplate.getSession(GrailsHibernateTemplate.java:225)
org.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:183)
org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:140)
org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:110)
org.grails.orm.hibernate.AbstractHibernateGormStaticApi.findWhere(AbstractHibernateGormStaticApi.groovy:335)
org.grails.datastore.gorm.GormStaticApi.findWhere(GormStaticApi.groovy:658)
org.grails.datastore.gorm.GormEntity$Trait$Helper.findWhere(GormEntity.groovy:841)
org.grails.datastore.gorm.GormEntity$Trait$Helper$findWhere$4.call(Unknown Source)
com.etherapia.portal.security.User.findWhere(User.groovy)
com.etherapia.portal.security.User$findWhere$0.call(Unknown Source)
grails.plugin.springsecurity.userdetails.GormUserDetailsService.$tt__loadUserByUsername(GormUserDetailsService.groovy:60)
grails.plugin.springsecurity.userdetails.GormUserDetailsService$_loadUserByUsername_closure1.doCall(GormUserDetailsService.groovy)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
錯誤只顯示在mozzila firefox中,而chroome加載頁面沒有資產。圖像,css,js在chroome中未正確加載。
你知道哪裏可能是一個問題?
錯誤所在位置:com.etherapia.portal.security.User.findWhere(User.groovy) com.etherapia.portal.security.User $ findWhere $ 0.call(來源不明) grails.plugin (GormUserDetailsService.groovy:60) grails.plugin.springsecurity.userdetails.GormUserDetailsService $ _loadUserByUsername_closure1.doCall(GormUserDetailsService.groovy)實際的錯誤是org.hibernate.HibernateException:沒有找到當前會話線。也許你需要將它包裝在@Transactional中 - 恐怕不是很多。 – Vahid
你解決了你的問題嗎?我面對同樣的事情,沒有休眠會話時應該有 –
@ Chris.D是的,不幸的是我不記得如何。據我記得,我們回滾了我在升級過程中所做的一些更改。然後我們在第二次嘗試升級時沒有遇到錯誤,所以我們很高興,但是我可能沒有解決問題。從那以後,我升級了另一個項目,但我也沒有遇到這個問題。我很抱歉,我無法幫助你。 :( –