StaleObjectStateException invoicing supplier delivery

Description

From a 1.8 error report:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 org.openvpms.component.business.service.archetype.ArchetypeServiceException: Failed to save a collection of 43 objects. at org.openvpms.component.business.service.archetype.ArchetypeService.save(ArchetypeService.java:541) at sun.reflect.GeneratedMethodAccessor442.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:67) at org.openvpms.component.business.service.security.OpenVPMSMethodSecurityInterceptor.invoke(OpenVPMSMethodSecurityInterceptor.java:50) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy3.save(Unknown Source) at org.openvpms.component.business.service.archetype.rule.ArchetypeRuleService$2.run(ArchetypeRuleService.java:136) at org.openvpms.component.business.service.archetype.rule.ArchetypeRuleService$5.doInTransaction(ArchetypeRuleService.java:201) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.openvpms.component.business.service.archetype.rule.ArchetypeRuleService.execute(ArchetypeRuleService.java:196) at org.openvpms.component.business.service.archetype.rule.ArchetypeRuleService.save(ArchetypeRuleService.java:134) at org.openvpms.component.business.service.archetype.DelegatingArchetypeService.save(DelegatingArchetypeService.java:223) at org.openvpms.archetype.rules.supplier.OrderRules.invoiceSupplier(OrderRules.java:192) at org.openvpms.web.workspace.supplier.delivery.DeliveryCRUDWindow.invoice(DeliveryCRUDWindow.java:303) at org.openvpms.web.workspace.supplier.delivery.DeliveryCRUDWindow.access$300(DeliveryCRUDWindow.java:59) at org.openvpms.web.workspace.supplier.delivery.DeliveryCRUDWindow$4.onOK(DeliveryCRUDWindow.java:247) at org.openvpms.web.echo.dialog.PopupDialogListener.onAction(PopupDialogListener.java:129) at org.openvpms.web.echo.dialog.PopupDialogListener.onClose(PopupDialogListener.java:40) at org.openvpms.web.echo.event.WindowPaneListener.windowPaneClosing(WindowPaneListener.java:37) at nextapp.echo2.app.WindowPane.fireWindowClosing(WindowPane.java:154) at org.openvpms.web.echo.dialog.PopupWindow.fireWindowClosing(PopupWindow.java:215) at nextapp.echo2.app.WindowPane.userClose(WindowPane.java:795) at org.openvpms.web.echo.dialog.PopupDialog.userClose(PopupDialog.java:267) at org.openvpms.web.echo.dialog.MessageDialog.userClose(MessageDialog.java:109) at org.openvpms.web.echo.dialog.PopupWindow.close(PopupWindow.java:142) at org.openvpms.web.echo.dialog.PopupDialog.close(PopupDialog.java:422) at org.openvpms.web.echo.dialog.PopupDialog.onOK(PopupDialog.java:328) at org.openvpms.web.echo.dialog.PopupDialog.onButton(PopupDialog.java:299) at org.openvpms.web.echo.dialog.PopupDialog.onButtonProtected(PopupDialog.java:466) at org.openvpms.web.echo.dialog.PopupDialog.access$000(PopupDialog.java:34) at org.openvpms.web.echo.dialog.PopupDialog$3.onAction(PopupDialog.java:453) at org.openvpms.web.echo.event.ActionListener.actionPerformed(ActionListener.java:40) at nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135) at echopointng.ButtonEx$1.actionPerformed(ButtonEx.java:120) at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70) at echopointng.model.DefaultButtonModelEx.doAction(DefaultButtonModelEx.java:51) at echopointng.ButtonEx.processInput(ButtonEx.java:202) at nextapp.echo2.app.update.ClientUpdateManager.process(ClientUpdateManager.java:116) at nextapp.echo2.app.update.UpdateManager.processClientUpdates(UpdateManager.java:89) at nextapp.echo2.webcontainer.ContainerSynchronizeService.renderUpdate(ContainerSynchronizeService.java:471) at nextapp.echo2.webrender.service.SynchronizeService.service(SynchronizeService.java:279) at nextapp.echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:273) at org.openvpms.web.echo.servlet.SpringWebContainerServlet.process(SpringWebContainerServlet.java:178) at nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:189) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.openvpms.web.echo.servlet.Log4JMDCUserFilter.doFilter(Log4JMDCUserFilter.java:58) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source) Caused by: org.openvpms.component.business.dao.im.common.IMObjectDAOException: Failed to save a collection of objects at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.save(IMObjectDAOHibernate.java:193) at org.openvpms.component.business.service.archetype.ArchetypeService.save(ArchetypeService.java:531) ... 83 more Caused by: org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [org.openvpms.component.business.dao.hibernate.im.act.FinancialActDOImpl] with identifier [728488]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.openvpms.component.business.dao.hibernate.im.act.FinancialActDOImpl#728488] at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:672) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate$9$1.doInHibernate(IMObjectDAOHibernate.java:1094) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate$9.doInTransaction(IMObjectDAOHibernate.java:1090) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.update(IMObjectDAOHibernate.java:1088) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.save(IMObjectDAOHibernate.java:185) ... 84 more Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.openvpms.component.business.dao.hibernate.im.act.FinancialActDOImpl#728488] at org.openvpms.component.business.dao.hibernate.im.common.DOState.<init>(DOState.java:114) at org.openvpms.component.business.dao.hibernate.im.common.IMObjectAssembler.assemble(IMObjectAssembler.java:100) at org.openvpms.component.business.dao.hibernate.im.common.CompoundAssembler.assemble(CompoundAssembler.java:90) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.save(IMObjectDAOHibernate.java:887) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.save(IMObjectDAOHibernate.java:905) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate.access$100(IMObjectDAOHibernate.java:97) at org.openvpms.component.business.dao.hibernate.im.IMObjectDAOHibernate$2.doInHibernate(IMObjectDAOHibernate.java:188) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) ... 92 more

This occurs when invoicing a supplier delivery immediately after finalising it.
It can be worked around by locating the Finalised delivery, and invoicing it separately.

Environment

None

Status

Assignee

Tim Anderson

Reporter

Tim Anderson

Labels

None

Components

Fix versions

Affects versions

1.8

Priority

Minor