Friday, 27 January 2012

com.ibm.ejs.persistence.OptimisticUpdateFailureException: executeUpdate returned zero rows updated

Problem:
The exception OptimisticUpdateFailureException is continuously showing up in your WebSphere Commerce logs even in your own development machine where there isn't a possibility for multiple transactions on the same  tables.
Hint: According to my reading, this exception might happen in case two transactions tried to update the same row in a table and you need to catch and handle the situation. But I am not talking about this particular scenario.

Exception:
CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "findByOrderAndStore".
Exception data: com.ibm.ws.exception.WsEJBException: nested exception is: com.ibm.websphere.csi.CSIException: Problem storing CMP 1.x or BMP bean; nested exception is:
      com.ibm.ejs.container.CacheFlushFailure: ; nested exception is:
      com.ibm.ejs.persistence.OptimisticUpdateFailureException: executeUpdate returned zero rows updated
      at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.flush(ConcreteBeanStatefulInstanceExtensionImpl.java:718)
      at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.executeQuery(ConcreteBeanStatefulInstanceExtensionImpl.java:1648)
      at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.executeFind(ConcreteBeanStatefulInstanceExtensionImpl.java:1558)
      at com.ibm.commerce.edp.model.ConcreteEDPOrder_9a2637b5.ejbFindByOrderAndStore_Local(ConcreteEDPOrder_9a2637b5.java:107)
      at com.ibm.commerce.edp.model.EJSCMPEDPOrderHomeBean_9a2637b5.findByOrderAndStore_Local(EJSCMPEDPOrderHomeBean_9a2637b5.java:62)
      at com.ibm.commerce.edp.model.EJSLocalCMPEDPOrderHome_9a2637b5.findByOrderAndStore(EJSLocalCMPEDPOrderHome_9a2637b5.java:68)
      at com.ibm.commerce.edp.model.EDPOrderFactory.findByPrimaryKey(EDPOrderFactory.java:71)
      at com.ibm.commerce.edp.model.ObjectModelFacadeBean.getEDPOrderEJB(ObjectModelFacadeBean.java:2046)
      at com.ibm.commerce.edp.model.ObjectModelFacadeBean.getPis(ObjectModelFacadeBean.java:443)
      at com.ibm.commerce.edp.model.EJSLocalStatelessObjectModelFacade_331c2a24.getPis(EJSLocalStatelessObjectModelFacade_331c2a24.java:751)
      at com.ibm.commerce.payment.rules.QueryHandler.getPaymentInstructionsInOrder(QueryHandler.java:1274)
      at com.ibm.commerce.edp.commands.EDPPaymentInstructionsBeanCmdImpl.performExecute(EDPPaymentInstructionsBeanCmdImpl.java:85)
      at com.ibm.commerce.command.ECCommandTarget.executeCommand(ECCommandTarget.java:157)
      at com.ibm.websphere.command.TargetableCommandImpl.execute(TargetableCommandImpl.java:139)
      at com.ibm.websphere.command.CacheableCommandImpl.execute(CacheableCommandImpl.java:138)
      at com.ibm.commerce.command.AbstractECTargetableCommand.execute(AbstractECTargetableCommand.java:172)
      at com.ibm.commerce.beans.DataBeanManager.populateDataBean(DataBeanManager.java:542)
      at com.ibm.commerce.beans.DataBeanManager.activate(DataBeanManager.java:119)
      at com.ibm.commerce.beans.DataBeanManager.activate(DataBeanManager.java:90)
      at com.weare2020.commerce.edp.util.GiftVoucherUtil.getGiftVouchers(GiftVoucherUtil.java:227)
      at com.weare2020.giftvouchers.beans.GiftVoucherProcessBean.getGiftVoucherDetailForOrder(GiftVoucherProcessBean.java:45)
      at com.weare2020.giftvouchers.beans.GiftVoucherProcessBean.populate(GiftVoucherProcessBean.java:27)

Fix:
If you have custom tables/EJBs created, revisit their implementation and make sure in all your custom tables, you created column OPTCOUNTER as well as a variable to hold its value in the EJB. This column is important for optimistic locking to work properly.

For more information, please check:


No comments:

Post a Comment