Any best practice to deal with javax.persistence.OptimisticLockException?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Any best practice to deal with javax.persistence.OptimisticLockException?

Yun Jie Zhou
Hello experts,
 
We got some OptimisticLockException in updating operations. Because it is Unchecked Exception, we cannot use try/catch with update operations. I searched the archived mail list, but didn't figure out a solution. Any best practice to add retry logic for concurrent access?
 
 
Exception = javax.ejb.EJBTransactionRolledbackException
Source = com.ibm.ejs.container.LocalExceptionMappingStrategy.setUncheckedException
probeid = 178
Stack Dump = javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: javax.persistence.OptimisticLockException: Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.6.3.WAS-v20160817-8475a53): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] cannot be updated because it has changed or been deleted since it was last read.
Class> com.ibm.xxxxxx.domain.jpa.SvcDump Primary Key>
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSIException(BusinessExceptionMappingStrategy.java:124)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSITransactionRolledBackException(BusinessExceptionMappingStrategy.java:584)
    at com.ibm.ejs.container.EJSDeployedSupport.mapCSITransactionRolledBackException(EJSDeployedSupport.java:600)
    at com.ibm.ejs.container.EJSContainer.postInvokeRolledbackException(EJSContainer.java:4382)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4073)
    at com.ibm.xxxxxx.service.EJSLocalNSLAppConfigService_f6f99969.getOrCreateAppConfig(EJSLocalNSLAppConfigService_f6f99969.java)
    at com.ibm.xxxxxx.scheduler.AbstractScheduler.schedule(AbstractScheduler.java)
    at com.ibm.xxxxxx.scheduler.SvcDumpUpdater.run(SvcDumpUpdater.java)
    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 com.ibm.ejs.container.TimedObjectWrapper.invokeCallback(TimedObjectWrapper.java:103)
    at com.ibm.ejs.container.TimerNpRunnable.doWork(TimerNpRunnable.java:196)
    at com.ibm.ejs.container.TimerNpRunnable.run(TimerNpRunnable.java:103)
    at com.ibm.ejs.container.TimerNpRunnable.run(TimerNpRunnable.java:143)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    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: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: javax.persistence.OptimisticLockException: Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.6.3.WAS-v20160817-8475a53): org.eclipse.persistence.exceptions.OptimisticLockException
Thanks & Best Regards
 


_______________________________________________
eclipselink-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev