Java – spring hibernate 5 error value [org.springframework.orm.hibernate5.sessionholder used for key binding to thread
•
Java
I just upgraded to hibernate 5 when trying to use getcurrentsession using spring hibernate transaction manager and faced the following error
org.springframework.orm.hibernate5.HibernateTransactionManager
This is the full stack trace of the error
java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate5.SessionHolder@c05f59] for key [org.hibernate.internal.SessionFactoryImpl@f0db1] bound to thread [http-bio-8080-exec-3] at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:190) ~[spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:129) ~[spring-orm-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:692) ~[hibernate-core-5.0.2.Final.jar:5.0.2.Final] at com.pos.core.repository.persistance.framework.impl.BaseHibernateRepository.getCurrentSession(BaseHibernateRepository.java:42) ~[Core-2.5.2-SNAPSHOT.jar:?] at com.pos.infrastructure.security.repository.impl.LoginSessionRepositoryImpl.getLoginSessionInfo(LoginSessionRepositoryImpl.java:83) ~[Infrastructure-2.5.2-SNAPSHOT.jar:?] at com.pos.infrastructure.authentication.services.impl.AuthenticationServiceImpl.checkLoginSessionInfo(AuthenticationServiceImpl.java:1087) ~[Infrastructure-2.5.2-SNAPSHOT.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE] at com.sun.proxy.$Proxy168.checkLoginSessionInfo(UnkNown Source) [?:?] at com.pos.posservice.interceptors.WebServiceInterceptor.checkToken(WebServiceInterceptor.java:161) [WebServiceInterceptor.class:?]
Solution
I found a solution to the problem I am using hibernate 4 SF bean
org.springframework.orm.hibernate4.LocalSessionfactorybean
I had to change it to hibernate 5 SF bean to solve the problem
org.springframework.orm.hibernate5.LocalSessionfactorybean
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码