Issue 295 in flyway: java.sql.SQLException: You cannot set autocommit during a managed transaction!

346 views
Skip to first unread message

fly...@googlecode.com

unread,
Jul 17, 2012, 6:41:09 AM7/17/12
to flywa...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 295 by dalibor....@gmail.com: java.sql.SQLException: You cannot
set autocommit during a managed transaction!
http://code.google.com/p/flyway/issues/detail?id=295

Hi there,

I have simple EJB 3.1 Bean (Singleton, Startup) deployed inside JBoss 7.1.1
which performs migration. But I get following exception:

Caused by: com.googlecode.flyway.core.exception.FlywayException: Migration
failed !
at
com.googlecode.flyway.core.migration.DbMigrator.migrate(DbMigrator.java:165)
at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:608)
at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:591)
at com.googlecode.flyway.core.Flyway.execute(Flyway.java:882)
at com.googlecode.flyway.core.Flyway.migrate(Flyway.java:591)
at
ch.dvbern.stvbe.neskovaesn.service.FlywayMigration.startup(FlywayMigration.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rt.jar:1.6.0_31]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[rt.jar:1.6.0_31]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rt.jar:1.6.0_31]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_31]
at
org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:73)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:112)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
[jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
... 18 more
Caused by: com.googlecode.flyway.core.util.jdbc.TransactionException:
Error while executing transaction. Roll back failed!
at
com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:63)
at
com.googlecode.flyway.core.migration.DbMigrator.migrate(DbMigrator.java:113)
... 44 more
Caused by: java.sql.SQLException: You cannot set autocommit during a
managed transaction!
at
org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:888)
at
org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:715)
at
com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:53)
... 45 more

Is there any way how to tell flyway that migration is performed in
container?
Thank you and best regards,
Dalibor Kalna

fly...@googlecode.com

unread,
Jul 17, 2012, 6:42:30 AM7/17/12
to flywa...@googlegroups.com

Comment #1 on issue 295 by dalibor....@gmail.com: java.sql.SQLException:
You cannot set autocommit during a managed transaction!
http://code.google.com/p/flyway/issues/detail?id=295

Sorry, I'm using flyway 1.7

fly...@googlecode.com

unread,
Jul 17, 2012, 7:14:31 AM7/17/12
to flywa...@googlegroups.com

Comment #2 on issue 295 by axel.fontai...@gmail.com:
java.sql.SQLException: You cannot set autocommit during a managed
transaction!
http://code.google.com/p/flyway/issues/detail?id=295

Hi Dalibor,

Thanks for your report. Could you annotate your ejb with
@TransactionManagement(TransactionManagementType.BEAN) and let me know if
it works? If it doesn't, could you then also post the source of your ejb?

Thanks
Axel

fly...@googlecode.com

unread,
Jul 18, 2012, 6:21:33 AM7/18/12
to flywa...@googlegroups.com

Comment #3 on issue 295 by dalibor....@gmail.com: java.sql.SQLException:
You cannot set autocommit during a managed transaction!
http://code.google.com/p/flyway/issues/detail?id=295

Hi Axel,

yes, that did the trick. Thank you and best regards,

Dalibor

fly...@googlecode.com

unread,
Jul 18, 2012, 8:48:46 AM7/18/12
to flywa...@googlegroups.com
Updates:
Status: WontFix

Comment #8 on issue 295 by axel.fontai...@gmail.com:
java.sql.SQLException: You cannot set autocommit during a managed
transaction!
http://code.google.com/p/flyway/issues/detail?id=295

(No comment was entered for this change.)

fly...@googlecode.com

unread,
May 28, 2013, 10:22:18 AM5/28/13
to flywa...@googlegroups.com

Comment #9 on issue 295 by cprenzb...@googlemail.com:
java.sql.SQLException: You cannot set autocommit during a managed
transaction!
http://code.google.com/p/flyway/issues/detail?id=295

awesome this also solved my issue!

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages