Hello,
I am facing an issue and I can't seem to find a solution.
I am migrating a project from Hibernate 5.1.1 to 5.2.2 and Spring from 4.1.0 to 4.3.3.
Using weblogic, when I try to deploy my ear I get a TransactionRequiredException: no transaction is in progress.
This happens on a bean that is supposed to make a lot of queries to the database, and the method is annotated @PostConstruct.
It was working fine before, I updated my hibernate configuration according to the migration guide and I can't seem to find the solution.
This is the modified configuration for Hibernate 5.2.2 :
Code:
<prop key="hibernate.transaction.coordinator_class">jta</prop>
<!-- How to produce transaction -->
<prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform</prop>
This is an extract of the server log :
Code:
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3428) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1395) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1391) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
at org.springframework.orm.hibernate5.SessionFactoryUtils.flush(SessionFactoryUtils.java:144) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.hibernate5.SpringSessionSynchronization.beforeCommit(SpringSessionSynchronization.java:95) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:932) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:744) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:487) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at com.sun.proxy.$Proxy408.findAll(Unknown Source) ~[?:?]
It was working fine before my migration attempt and I suppose it is related to the fact that the bean is initialized but the transaction is closed.
What is strange is that when I debug the method, I am able to get the first few calls to the database but it fails later on.
In both cases I am using :
Code:
getHibernateTemplate().executeWithNativeSession(new HibernateCallback<List<E>>()
Has anyone of you encountered this kind of problem?
I googled days long and I can't find a single answer corresponding to this problem (btw. this also happens on my Junit tests)
Thanks in advance for your help.
Cheers,
Speed.