4 Replies Latest reply on Apr 21, 2017 2:55 PM by Cdelahun-Oracle

    Cannot use commit() method to commit UnitOfWork again..

    Azhar Altaf

      Hello everyone,


      I am using Toplink web based application using EJBSessionBean...

      I created my own View java class for showing some DB table data on UserInterface.

      I have manually created find and saveViewList() methods in SessionEJBBean.java and created DataControl and drag into UserInterface.


      When I click save button which calls saveViewList() method. In saveViewList(), i use commit method as shown below:


      When compiler reaches to commit method, it shows error on runtime as follows:


      Local Exception Stack:

      Exception [EclipseLink-7096] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.ValidationException

      Exception Description: Cannot use commit() method to commit UnitOfWork again.

        at org.eclipse.persistence.exceptions.ValidationException.cannotCommitUOWAgain(ValidationException.java:572)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commit(UnitOfWorkImpl.java:1084)

        at pk.paf.iscmd.piccs.fms.fighter.model.helper.TransactionHelper.persistEntity(TransactionHelper.java:33)

        at pk.paf.iscmd.piccs.fms.fighter.model.view.fpb.XEssExcListView.relay(XEssExcListView.java:76)

        at pk.paf.iscmd.piccs.fms.fighter.model.SessionEJBBean.saveView(SessionEJBBean.java:158)

        at pk.paf.iscmd.piccs.fms.fighter.model.SessionEJBBean.saveViewList(SessionEJBBean.java:186)

        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.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)

        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)

        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)

        at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)

        at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:101)

        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)

        at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:101)

        at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73)

        at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)

        at sun.reflect.GeneratedMethodAccessor273.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:94)

        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)

        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)

        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)

        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)

        at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)

        at com.sun.proxy.$Proxy295.saveViewList(Unknown Source)

        at pk.paf.iscmd.piccs.fms.fighter.model.SessionEJB_qxt9um_SessionEJBLocalImpl.__WL_invoke(Unknown Source)

        at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:33)

        at pk.paf.iscmd.piccs.fms.fighter.model.SessionEJB_qxt9um_SessionEJBLocalImpl.saveViewList(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.



      It says, it cannot commit use commit() method to commit UnitOfWork again...?????


      Plz guide..




        • 1. Re: Cannot use commit() method to commit UnitOfWork again..
          Timo Hahn

          Well, you are posting this in the wrong forum. We are not specialized on TopLink or EclipseLink here and you problem is clearly related to EclipseLink. Please poet question related to EclipseLimk in an forum for this product like TopLink/JPA


          As you are looking to be a newcomer on this you should google for the exception and you'll find UnitOfWork (EclipseLink 1.0.2_1.0.2 20081024 API Reference) where you read

          If the commit is successful the unit of work is released, and a new unit of work must be acquired if further changes are desired.

          Meaning what you see is by design. You have to aquire a new UOW once you have committed one OR if you look at the commitAndResume() method

          PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, and the unit of work will be released. The normal commit releases the unit of work, forcing a new one to be acquired if further changes are desired. The resuming feature allows for the same unit of work (and working copies) to be continued to be used.

          it will commit but you can use the same UOW again.



          • 3. Re: Cannot use commit() method to commit UnitOfWork again..
            Azhar Altaf

            Sometimes, while debugging, the server passes thru " uow.commit" statement and after that in the end, it displays the general error:


            Error while Committing, So RollBack...... So no transaction is commited..


            I have attached the merge and persist methods, plz suggest, if there is something wrong in this code.... I just pass the viewList (coming from User-Interface as a List of rows and each row is an object of my bean class)...


            This same technique worked fine when I was using JDev 10.1.3, but now I started to use JDev and this code doesn't work..

            I am struck in this code for more than 01 week, and couldn't find any solution.. Now, I disappointed. Someone has suggested me to leave Toplink and start working with ADF. But i don't want coz I have been working in Toplink projects for 9 years in JDev 10.1.3.


            Plz guide, as u people are Toplink specialists....



            • 4. Re: Cannot use commit() method to commit UnitOfWork again..

              The error stack trace shows that TransactionHelper.persistEntity is making the call to the UnitOfWork.  How are you obtaining the UOW?  This code has not changed, so somehow you must be reusing a UnitOfWork or made some other change, like associating it to an external transaction that might be commiting in some other thread context.  You might try turning on TopLink/EclipseLink logging to see what might be happening to this UnitOfWork.