[keycloak-dev] java.sql.SQLException: IJ031017: You cannot set autocommit during a managed transaction

Dmitry Telegin mitya at cargosoft.ru
Thu Sep 22 18:20:15 EDT 2016


Hi,

In my custom RealmResourceProviderFactory, I do roughly the following:

    @Override    public void postInit(KeycloakSessionFactory factory)
{        KeycloakModelUtils.runJobInTransaction(factory,
(KeycloakSession session) -> {            List<RealmModel> realms =
session.realms().getRealms();            ...	});    });
Full code here: https://github.com/dteleguin/custom-admin-roles

Everything worked fine with 2.1.x, but after upgrade to 2.2.x startup
fails in roughly about 50% cases:

Caused by: java.sql.SQLException: IJ031017: You cannot set autocommit
during a managed transaction	at
org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCom
mit(BaseWrapperManagedConnection.java:994)	at
org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConn
ection.java:787)	at
org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplement
or.begin(AbstractLogicalConnectionImplementor.java:67)	at
org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.begin
(LogicalConnectionManagedImpl.java:238)	at
org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLo
calTransactionCoordinatorImpl$TransactionDriverControlImpl.begin(JdbcRe
sourceLocalTransactionCoordinatorImpl.java:214)	at
org.hibernate.engine.transaction.internal.TransactionImpl.begin(Transac
tionImpl.java:52)	at
org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:15
12)	at
org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:4
5)
Full stacktrace here: http://pastebin.com/ETtPqXQk

In the other half of cases, everything goes fine just like before, so
it's a kind of heisenbug. Any ideas? Could it be some concurrency issue
when my code is executed in parallel with some other DB-related code?
could it be JTA related?

Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160923/cda84fee/attachment.html 


More information about the keycloak-dev mailing list