HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.36k stars 493 forks source link

write transaction not working with Spring 5 and Hibernate 5 #187

Open piccolo1810 opened 7 years ago

piccolo1810 commented 7 years ago

Hi,

I using the following:

The application works fine without dcevm and hotswapagent but it crashes when I enabled it using the jvm parameters "-javaagent:C:\work\hotswap\hotswap-agent-1.1.0-SNAPSHOT.jar -XXaltjvm=dcevm"

Read transaction is working. The problem occurs when I try to do a write transaction. I googled to find a solution and so far nothing except for someone who encountered same issue as me, the link is http://stackoverflow.com/questions/40190515/hibernate-spring-transactional-no-transaction-is-in-progress

The stack trace is:

ERROR web.action.CRUDAction - no transaction is in progress javax.persistence.TransactionRequiredException: no transaction is in progress at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3450) ~[hibernate-core-5.2.8.Final.jar:5.2.8.Final] at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1418) ~[hibernate-core-5.2.8.Final.jar:5.2.8.Final] at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1414) ~[hibernate-core-5.2.8.Final.jar:5.2.8.Final] at org.springframework.orm.hibernate5.SessionFactoryUtils.flush(SessionFactoryUtils.java:144) ~[spring-orm-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.orm.hibernate5.SpringSessionSynchronization.beforeCommit(SpringSessionSynchronization.java:95) ~[spring-orm-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:916) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:724) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:708) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at com.sun.proxy.$Proxy132.update(Unknown Source) ~[?:?]

skybber commented 7 years ago

Could you try to disable Spring plugin to check if it is spring plugin issue? using: -javaagent:...hotswap-agent.jar=disablePlugin=Spring

piccolo1810 commented 7 years ago

Hi skybber,

I changed to "-javaagent:C:\work\hotswap\hotswap-agent-1.1.0-SNAPSHOT.jar=disablePlugin=Spring -XXaltjvm=dcevm" but still get same issue.

skybber commented 7 years ago

You can check =disablePlugin=Hibernate=disablePlugin=Proxy. (If not helps you can try to disable another plugins to find out the problematic one)

piccolo1810 commented 7 years ago

Now it works fine! So the issue is the Hibernate plugin.

Blackgen commented 6 years ago

Any news on this Issue? I've recently upgraded Spring & Hibernate, get the same Exception since then. Spring: 5.0.1 Hibernate: 5.2.9 Tomcat: 8.5 HotswapAgent: 1.3.0

Disabling the Hibernate Plugin solves the problem.

milikicn commented 6 years ago

Having the same issue with Hibernate 5.2.17.Final (Spring 4.3.8.RELEASE, Tomcat 8.5.9, HotswapAgent 1.3.0)

revilo464 commented 2 years ago

Also having this issue: Spring: 5.1.20 Hibernate: 5.3.20 Tomcat: 7.0.70 HotswapAgent: 1.4.2

Disabling Hibernate plugin also fixes it for me.