org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction]

Hibernate JIRA | Andrei Ivanov | 10 months ago
  1. 0

    I've got an exception without the proper cause, making it difficult to understand what happened: {noformat} org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction] at org.quartz.core.JobRunShell.run(JobRunShell.java:213) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:526) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70) at facade.impl.PersonsFacadeImpl.syncManager(PersonsFacadeImpl.java:261) at facade.impl.PersonsFacadeImpl.lambda$11(PersonsFacadeImpl.java:252) at java.util.ArrayList.forEach(ArrayList.java:1249) at facade.impl.PersonsFacadeImpl.syncManagers_aroundBody2(PersonsFacadeImpl.java:252) at facade.impl.PersonsFacadeImpl$AjcClosure3.run(PersonsFacadeImpl.java:1) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:66) at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:72) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70) at facade.impl.PersonsFacadeImpl.syncManagers(PersonsFacadeImpl.java:247) 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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) at com.sun.proxy.$Proxy85.syncManagers(Unknown Source) at facade.job.PersonsSyncJob.executeInternal(PersonsSyncJob.java:21) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ... 3 more Caused by: javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:86) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) ... 38 more {noformat} Using a breakpoint in {{TransactionImpl}} I see {{wrappedException = e.getCause();}} (line 70), which returns {{null}}. In my case, the exception was {{javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session}}. I assume a check should be done and use the exception itself if the _cause_ is {{null}}.

    Hibernate JIRA | 10 months ago | Andrei Ivanov
    org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction]
  2. 0

    I've got an exception without the proper cause, making it difficult to understand what happened: {noformat} org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction] at org.quartz.core.JobRunShell.run(JobRunShell.java:213) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:526) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70) at facade.impl.PersonsFacadeImpl.syncManager(PersonsFacadeImpl.java:261) at facade.impl.PersonsFacadeImpl.lambda$11(PersonsFacadeImpl.java:252) at java.util.ArrayList.forEach(ArrayList.java:1249) at facade.impl.PersonsFacadeImpl.syncManagers_aroundBody2(PersonsFacadeImpl.java:252) at facade.impl.PersonsFacadeImpl$AjcClosure3.run(PersonsFacadeImpl.java:1) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:66) at org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:72) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70) at facade.impl.PersonsFacadeImpl.syncManagers(PersonsFacadeImpl.java:247) 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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) at com.sun.proxy.$Proxy85.syncManagers(Unknown Source) at facade.job.PersonsSyncJob.executeInternal(PersonsSyncJob.java:21) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ... 3 more Caused by: javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:86) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) ... 38 more {noformat} Using a breakpoint in {{TransactionImpl}} I see {{wrappedException = e.getCause();}} (line 70), which returns {{null}}. In my case, the exception was {{javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session}}. I assume a check should be done and use the exception itself if the _cause_ is {{null}}.

    Hibernate JIRA | 10 months ago | Andrei Ivanov
    org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction]
  3. 0

    Error creating bean with name 'jpaAuditingHandler' on application shutdown

    Stack Overflow | 5 months ago | Nicolas Labrot
    org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hello, When my application shutdown I got this exception: {code} org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:526) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at com.victorbuckservices.vbackbone.common.transaction.DoInTransactionService$$EnhancerBySpringCGLIB$$4c864b6e.execute(<generated>) at com.victorbuckservices.vbackbone.service.distribution.fax.service.DistributionFaxService.particularRslFolderPolling(DistributionFaxService.java:757) at com.victorbuckservices.vbackbone.service.distribution.fax.service.DistributionFaxService.rslPolling(DistributionFaxService.java:723) at com.victorbuckservices.vbackbone.service.distribution.fax.service.DistributionFaxService$$FastClassBySpringCGLIB$$7c544f09.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651) at com.victorbuckservices.vbackbone.service.distribution.fax.service.DistributionFaxService$$EnhancerBySpringCGLIB$$75a0516b.rslPolling(<generated>) at com.victorbuckservices.vbackbone.service.distribution.fax.quartz.PollingJob.execute(PollingJob.java:28) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) Caused by: javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:94) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) ... 17 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'jpaAuditingHandler': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) {code} Some tasks must be finished prior to the shutdown and because spring is shutting down, it forbids call to DefaultSingletonBeanRegistry#getSingleton and thus AuditingEntityListener#touchForUpdate failed because he used an ObjectFactory<AuditingHandler>: {code:java} @PreUpdate public void touchForUpdate(Object target) { if (handler != null) { handler.getObject().markModified(target); } } {code}

    Spring JIRA | 5 months ago | Nicolas Labrot
    org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
  6. 0

    Hibernate NamedQuery and Pagination

    Stack Overflow | 2 years ago | DruidKuma
    org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly

  1. Malcshour 6 times, last 6 months ago
  2. thiago.santos 10 times, last 7 months ago
7 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. javax.persistence.RollbackException

    Error while committing the transaction

    at org.hibernate.jpa.internal.TransactionImpl.commit()
  2. org.hibernate.jpa
    TransactionImpl.commit
    1. org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:86)
    1 frame
  3. Spring ORM
    JpaTransactionManager.doCommit
    1. org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
    1 frame
  4. Spring Tx
    TransactionAspectSupport.invokeWithinTransaction
    1. org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
    2. org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
    3. org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
    4. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
    4 frames
  5. Spring Aspects
    AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c
    1. org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70)
    1 frame
  6. facade.impl
    PersonsFacadeImpl.lambda$11
    1. facade.impl.PersonsFacadeImpl.syncManager(PersonsFacadeImpl.java:261)
    2. facade.impl.PersonsFacadeImpl.lambda$11(PersonsFacadeImpl.java:252)
    2 frames
  7. Java RT
    ArrayList.forEach
    1. java.util.ArrayList.forEach(ArrayList.java:1249)
    1 frame
  8. facade.impl
    PersonsFacadeImpl$AjcClosure3.run
    1. facade.impl.PersonsFacadeImpl.syncManagers_aroundBody2(PersonsFacadeImpl.java:252)
    2. facade.impl.PersonsFacadeImpl$AjcClosure3.run(PersonsFacadeImpl.java:1)
    2 frames
  9. Spring Aspects
    AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation
    1. org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed(AbstractTransactionAspect.aj:66)
    2. org.springframework.transaction.aspectj.AbstractTransactionAspect$AbstractTransactionAspect$1.proceedWithInvocation(AbstractTransactionAspect.aj:72)
    2 frames
  10. Spring Tx
    TransactionAspectSupport.invokeWithinTransaction
    1. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    1 frame
  11. Spring Aspects
    AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c
    1. org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:70)
    1 frame
  12. facade.impl
    PersonsFacadeImpl.syncManagers
    1. facade.impl.PersonsFacadeImpl.syncManagers(PersonsFacadeImpl.java:247)
    1 frame
  13. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:498)
    4 frames
  14. Spring AOP
    ReflectiveMethodInvocation.proceed
    1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
    2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    4. org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58)
    5. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    5 frames
  15. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    3 frames
  16. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    4 frames
  17. com.sun.proxy
    $Proxy85.syncManagers
    1. com.sun.proxy.$Proxy85.syncManagers(Unknown Source)
    1 frame
  18. facade.job
    PersonsSyncJob.executeInternal
    1. facade.job.PersonsSyncJob.executeInternal(PersonsSyncJob.java:21)
    1 frame
  19. Spring Context Support
    QuartzJobBean.execute
    1. org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
    1 frame
  20. quartz
    JobRunShell.run
    1. org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    1 frame
  21. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    3. java.lang.Thread.run(Thread.java:745)
    3 frames