quarkus: javax.persistence.TransactionRequiredException thrown when trying to persist an entity

Describe the bug No transaction is being created while trying to persist an entity in a method annotated with @Transactional

Expected behavior The entity is persisted in the database

Actual behavior An Exception is thrown trying to persist the entity

2019-05-29 07:18:50,652 WARN  [com.arj.ats.arjuna] (executor-thread-1) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffac126e23:c210:5cee14fe:3, io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager$1@7b1c0a13 >: javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:398)
	at org.hibernate.internal.SessionImpl.checkTransactionNeededForUpdateOperation(SessionImpl.java:3619)
	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1474)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1470)
...
2019-05-29 07:18:50,663 ERROR [io.und.request] (executor-thread-1) UT005023: Exception handling request to /checkers/register: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Error invoking subclass method
	at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
	at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
...
Caused by: java.lang.RuntimeException: Error invoking subclass method
	at com.dwitech.ib24.checker.boundary.Checkers_Subclass.register(Unknown Source)
	at com.dwitech.ib24.checker.boundary.Checkers_ClientProxy.register(Unknown Source)
	at com.dwitech.ib24.checker.boundary.CheckersEndpoint.register(CheckersEndpoint.java:32)
	at com.dwitech.ib24.checker.boundary.CheckersEndpoint_Subclass.register$$superaccessor1(Unknown Source)
	at com.dwitech.ib24.checker.boundary.CheckersEndpoint_Subclass$$function$$3.apply(Unknown Source)
	at io.quarkus.arc.InvocationContextImpl.interceptorChainCompleted(InvocationContextImpl.java:157)
	at io.quarkus.arc.InvocationContextImpl.proceed(InvocationContextImpl.java:177)
	at io.smallrye.metrics.interceptors.MeteredInterceptor.meteredCallable(MeteredInterceptor.java:79)
	at io.smallrye.metrics.interceptors.MeteredInterceptor.meteredMethod(MeteredInterceptor.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.quarkus.arc.Reflections.invokeMethod(Reflections.java:111)
	at io.smallrye.metrics.interceptors.MeteredInterceptor_Bean.intercept(Unknown Source)
...
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1300)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
	at io.quarkus.narayana.jta.runtime.NarayanaJtaProducers_ProducerMethod_transactionManager_9989455b3b53ac81c17ca945c636473b7202fe4e_ClientProxy.commit(Unknown Source)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.endTransaction(TransactionalInterceptorBase.java:152)
...
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:398)
	at org.hibernate.internal.SessionImpl.checkTransactionNeededForUpdateOperation(SessionImpl.java:3619)
	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1474)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1470)
	at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager$1.beforeCompletion(TransactionScopedEntityManager.java:76)
	at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:360)
	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:91)
	at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1288)

To Reproduce Steps to reproduce the behavior:

  1. Add the Hibernate with Panache extension
  2. Create an Entity extending PanacheEntity
  3. Create a method to persist the entity in a @ApplicationScoped class and annotate the method with @Transactional

Configuration

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="ib24-checker" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/ib24_user?useSSL=false" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="<mysql_password>" />
            <property name="hibernate.connection.autocommit" value="false"/>
            <property name="org.hibernate.flushMode" value="COMMIT"/>
        </properties>
    </persistence-unit>
</persistence>

Environment :

  • Output of uname -a or ver: Darwin DWI-MBP15-1 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Output of java -version: JDK8 u202
  • GraalVM version (if different from Java): 1.0.0-rc14
  • Quarkus version or git rev: 0.15.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

@dwamara yes, we do not support declaring multiple persistence units with application.properties right now but that’s certainly something we might want to do in the future. Please open an issue.

@emmanuelbernard I would prefer spending time on ^ rather than documenting 2 different methods of doing the same thing.