Login  Register

Re: Transaction problem with ofbiz-workflow start (geronimo issue????)

Posted by David E Jones-2 on Aug 08, 2006; 5:44am
URL: http://ofbiz.116.s1.nabble.com/XSD-schema-conversion-anyone-tp170452p170468.html


Without looking into it more, I'm not sure...

Which revision of OFBiz are you updating to?

The code you included in your last message for the tx management in  
the workflow engine is a little fishy, it it's not doing the suspend  
correctly and such. It should use the TransactionUtil.suspend method  
and not do it itself.

Still the way it is doing it should only cause warnings and hopefully  
allow things to continue just fine.

But yeah, changing it to use the TransactionUtil methods instead of  
the tm.suspect and tm.resume directly should solve the problem.

-David


On Aug 7, 2006, at 10:21 PM, David Garrett wrote:

> More Information ... Hopefully simplified:
>
> I try to start the ofbiz-workflow by calling an async service from  
> an event
> as follows
>     <request-map uri="processWf">
>         <security https="true" auth="true"/>
>         <event type="service" path="async" invoke="processWf"/>
>         <response name="success" type="view" value="main"/>
>         <response name="error" type="view" value="main"/>
>     </request-map>
> It calls the following service
>     <service name="processWf" engine="ofbiz-workflow"
> location="org.ofbiz.leadmgt" invoke="processWf" >
>         <description>Service for testing workflow engine</description>
>         <attribute name="communicationEventId" type="String"  
> mode="INOUT"
> optional="true"/>
>     </service>
>
> Then the problem is with nested transactions below
>
> ServiceEventHandler.invoke(...)
>   dispatcher.runAsync(serviceName, serviceContext); //  
> ServiceEventHandler
> line 290
>     ServiceDispatcher.runAsync(...)
>       // First transaction starts OK
>       beganTrans = TransactionUtil.begin(service.transactionTimeout);
> //ServiceDispatcher.runAsync line 498)
>       ...
>       engine.runAsync(...); //ServiceDispatcher.runAsync line 553)
>         WorkflowEngine.runAsync(...)
>           // 2nd transaction begin FAILS
>           beganTransaction = TransactionUtil.begin();
> //WorkflowEngine.runAsync line 100
>             ...
>             TransactionUtil.setTransactionBeginStack()   <==##  
> transaction
> already exists
>
>
> Why can't the second transaction begin?
>
> Should I start the workflow a different way which does not cause 2
> transactions.
>
> Do I need to remove the transaction within the workflow?
>
> Thanks
> David G
>
> -----Original Message-----
> From: David Garrett [mailto:[hidden email]]
> Sent: Tuesday, 8 August 2006 11:40 AM
> To: [hidden email]
> Subject: Transaction problem with ofbiz-workflow start (geronimo  
> issue????)
>
> Hi,
>
> I am trying to upgrade to a much more recent version of Ofbiz.
>
> The problem I have is starting a workflow with the orignial ofbiz-
> workflow
> (ie not trying to use Shark yet)
>
> I was wondering whether the transaction problem related to the  
> change to
> geronimo TM.
>
> I have a VERY simple workflow which is initiated with
> WorkflowEngine.runAsync(..)
>
> Any suggestions appreciated.
>
> It fails on:
>                 beganTransaction = TransactionUtil.begin();
>
> The code executed is very small ... In WorkflowEngine
>     public void runAsync(String localName, ModelService  
> modelService, Map
> context, GenericRequester requester, boolean persist) throws
> GenericServiceException {
>         // Suspend the current transaction
>         TransactionManager tm =  
> TransactionFactory.getTransactionManager();
>         if (tm == null) {
>             throw new GenericServiceException("Cannot get the  
> transaction
> manager; cannot run persisted services.");
>         }
>
>         Transaction parentTrans = null;
>         boolean beganTransaction = false;
>         try {
>             try {
>                 parentTrans = tm.suspend();
>                 beganTransaction = TransactionUtil.begin();  <======
> EXCEPTION GENERATED HERE!!!!
>                 //Debug.logInfo("Suspended transaction; began new: " +
> beganTransaction, module);
>             } catch (SystemException se) {
>                 Debug.logError(se, "Cannot suspend transaction: " +
> se.getMessage(), module);
>             } catch (GenericTransactionException e) {
>                 Debug.logError(e, "Cannot begin nested transaction:  
> " +
> e.getMessage(), module);
>             }
>
>
> The exception is as follows:
>
> 2006-08-08 11:22:51,099 (http-0.0.0.0-8443-Processor3) [
> ServiceDispatcher.java:468:DEBUG] [[ASync service started...-
> total:0.0,since last(Begin):0.0]] - 'leadmgt / processWf'
> 2006-08-08 11:22:58,700 (http-0.0.0.0-8443-Processor3) [
> TransactionUtil.java:530:WARN ]
> ---- exception report
> ----------------------------------------------------------
> WARNING: In setTransactionBeginStack a stack placeholder was  
> already in
> place, here is where the transaction began:
> Exception: java.lang.Exception
> Message: Tx Stack Placeholder
> ---- stack trace
> ---------------------------------------------------------------
> java.lang.Exception: Tx Stack Placeholder
> org.ofbiz.entity.transaction.TransactionUtil.setTransactionBeginStack(
> Transa
> ctionUtil.java:524)
> org.ofbiz.entity.transaction.TransactionUtil.begin
> (TransactionUtil.java:111)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 498)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 620)
> org.ofbiz.service.GenericDispatcher.runAsync(GenericDispatcher.java:
> 181)
> org.ofbiz.service.GenericDispatcher.runAsync(GenericDispatcher.java:
> 188)
> org.ofbiz.webapp.event.ServiceEventHandler.invoke
> (ServiceEventHandler.java:2
> 90)
> org.ofbiz.webapp.control.RequestHandler.runEvent
> (RequestHandler.java:407)
> <+++.-.-.-.-.-.... Snip>
> ----------------------------------------------------------------------
> ------
> ----
>
> 2006-08-08 11:22:58,700 (http-0.0.0.0-8443-Processor3) [
> TransactionUtil.java:532:WARN ]
> ---- exception report
> ----------------------------------------------------------
> WARNING: In setTransactionBeginStack a stack placeholder was  
> already in
> place, here is the current location:
> Exception: java.lang.Exception
> Message: Current Stack Trace
> ---- stack trace
> ---------------------------------------------------------------
> java.lang.Exception: Current Stack Trace
> org.ofbiz.entity.transaction.TransactionUtil.setTransactionBeginStack(
> Transa
> ctionUtil.java:531)
> org.ofbiz.entity.transaction.TransactionUtil.setTransactionBeginStack(
> Transa
> ctionUtil.java:525)
> org.ofbiz.entity.transaction.TransactionUtil.begin
> (TransactionUtil.java:111)
> org.ofbiz.entity.transaction.TransactionUtil.begin
> (TransactionUtil.java:57)
> org.ofbiz.workflow.WorkflowEngine.runAsync(WorkflowEngine.java:100)
> org.ofbiz.workflow.WorkflowEngine.runAsync(WorkflowEngine.java:82)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 553)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 620)
> org.ofbiz.service.GenericDispatcher.runAsync(GenericDispatcher.java:
> 181)
> org.ofbiz.service.GenericDispatcher.runAsync(GenericDispatcher.java:
> 188)
> org.ofbiz.webapp.event.ServiceEventHandler.invoke
> (ServiceEventHandler.java:2
> 90)
> org.ofbiz.webapp.control.RequestHandler.runEvent
> (RequestHandler.java:407)
> <+++.-.-.-.-.-.... Snip>
> ----------------------------------------------------------------------
> ------
> ----
>
> 2006-08-08 11:22:58,710 (http-0.0.0.0-8443-Processor3) [
> WfProcessMgrImpl.java:97 :INFO ] [WfProcessMgr.init] : Create process
> manager (org.ofbiz.leadmgt[null] / processWf[null])
> 2006-08-08 11:22:58,730 (http-0.0.0.0-8443-Processor3) [
> ServiceDispatcher.java:564:DEBUG] [[ASync service failed...-
> total:7.631,since last(ASync service sta...):7.631]] - 'leadmgt /  
> processWf'
> 2006-08-08 11:22:58,730 (http-0.0.0.0-8443-Processor3) [
> ServiceDispatcher.java:567:ERROR]
> ---- exception report
> ----------------------------------------------------------
> Service [processWf] threw an unexpected exception/error
> Exception: org.ofbiz.service.GenericServiceException
> Message: Cannot resume transaction (Caller context is not an  
> unspecified
> transaction context)
> ---- stack trace
> ---------------------------------------------------------------
> org.ofbiz.service.GenericServiceException: Cannot resume  
> transaction (Caller
> context is not an unspecified transaction context)
> org.ofbiz.workflow.WorkflowEngine.runAsync(WorkflowEngine.java:281)
> org.ofbiz.workflow.WorkflowEngine.runAsync(WorkflowEngine.java:82)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 553)
> org.ofbiz.service.ServiceDispatcher.runAsync(ServiceDispatcher.java:
> 620)
> org.ofbiz.service.GenericDispatcher.runAsync(GenericDispatcher.java:
> 181)
>
>
>
>