You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/05/27 22:28:17 UTC

svn commit: r1343088 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Author: jleroux
Date: Sun May 27 20:28:16 2012
New Revision: 1343088

URL: http://svn.apache.org/viewvc?rev=1343088&view=rev
Log:
Fixes this error found by chance in log

---- exception report ----------------------------------------------------------
ERROR: Cannot do a find that returns an EntityListIterator with no transaction in place. Wrap this call in a transaction.
Exception: java.lang.Exception
Message: Stack Trace
---- stack trace ---------------------------------------------------------------
java.lang.Exception: Stack Trace
org.ofbiz.entity.GenericDelegator.find(GenericDelegator.java:1751)
org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5610)
org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5605)

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1343088&r1=1343087&r2=1343088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun May 27 20:28:16 2012
@@ -5601,7 +5601,9 @@ public class OrderServices {
         }
         final EntityCondition cond = EntityCondition.makeCondition(orderCondList);
         List<String> orderIds;
+        boolean beganTransaction = false;
         try {
+            beganTransaction = TransactionUtil.begin();
             orderIds = TransactionUtil.doNewTransaction(new Callable<List<String>>() {
                 public List<String> call() throws Exception {
                     List<String> orderIds = new LinkedList<String>();
@@ -5622,8 +5624,20 @@ public class OrderServices {
             }, "getSalesOrderIds", 0, true);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
+            try {
+                TransactionUtil.rollback(beganTransaction, e.getMessage(), e);
+            } catch (GenericTransactionException e2) {
+                Debug.logError(e2, "Unable to rollback transaction", module);
+            }
             return ServiceUtil.returnError(e.getMessage());
+        } finally {
+            try {
+                TransactionUtil.commit(beganTransaction);
+            } catch (GenericTransactionException e) {
+                Debug.logError(e, "Unable to commit transaction", module);
+            }
         }
+
         for (String orderId: orderIds) {
             Map<String, Object> svcIn = FastMap.newInstance();
             svcIn.put("userLogin", context.get("userLogin"));



Re: svn commit: r1343088 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
From: "Adam Heath" <do...@brainfood.com>
> On 05/27/2012 03:28 PM, jleroux@apache.org wrote:
>> Author: jleroux
>> Date: Sun May 27 20:28:16 2012
>> New Revision: 1343088
>>
>> URL: http://svn.apache.org/viewvc?rev=1343088&view=rev
>> Log:
>> Fixes this error found by chance in log
>>
>> ---- exception report ----------------------------------------------------------
>> ERROR: Cannot do a find that returns an EntityListIterator with no transaction in place. Wrap this call in a transaction.
>> Exception: java.lang.Exception
>> Message: Stack Trace
>> ---- stack trace ---------------------------------------------------------------
>> java.lang.Exception: Stack Trace
>> org.ofbiz.entity.GenericDelegator.find(GenericDelegator.java:1751)
>> org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5610)
>> org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5605)
>>
>> Modified:
>>      ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
>>
>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1343088&r1=1343087&r2=1343088&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun May 27 20:28:16 2012
>> @@ -5601,7 +5601,9 @@ public class OrderServices {
>>           }
>>           final EntityCondition cond = EntityCondition.makeCondition(orderCondList);
>>           List<String>  orderIds;
>> +        boolean beganTransaction = false;
>>           try {
>> +            beganTransaction = TransactionUtil.begin();
>>               orderIds = TransactionUtil.doNewTransaction(new Callable<List<String>>() {
>>                   public List<String>  call() throws Exception {
>>                       List<String>  orderIds = new LinkedList<String>();
>
> Er, really?  This is not the correct fix.  Do you see that TransactionUtil.doNewTransaction call?  Do you understand what that
> does(or what it is supposed to do)?

Of course I saw it, but as it's not documented at all. Even if the code seems obvious, as it was not working, I decided to wrap it 
with another transaction with the hope that it would be better at least.

Jacques

> The real problem is in TransactionUtil.doNewTransaction, and it's my fault.
>
> I fixed the root cause in 1343469, then backed out your change in 1343470.

Re: svn commit: r1343088 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Posted by Adam Heath <do...@brainfood.com>.
On 05/27/2012 03:28 PM, jleroux@apache.org wrote:
> Author: jleroux
> Date: Sun May 27 20:28:16 2012
> New Revision: 1343088
>
> URL: http://svn.apache.org/viewvc?rev=1343088&view=rev
> Log:
> Fixes this error found by chance in log
>
> ---- exception report ----------------------------------------------------------
> ERROR: Cannot do a find that returns an EntityListIterator with no transaction in place. Wrap this call in a transaction.
> Exception: java.lang.Exception
> Message: Stack Trace
> ---- stack trace ---------------------------------------------------------------
> java.lang.Exception: Stack Trace
> org.ofbiz.entity.GenericDelegator.find(GenericDelegator.java:1751)
> org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5610)
> org.ofbiz.order.order.OrderServices$1.call(OrderServices.java:5605)
>
> Modified:
>      ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
>
> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1343088&r1=1343087&r2=1343088&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun May 27 20:28:16 2012
> @@ -5601,7 +5601,9 @@ public class OrderServices {
>           }
>           final EntityCondition cond = EntityCondition.makeCondition(orderCondList);
>           List<String>  orderIds;
> +        boolean beganTransaction = false;
>           try {
> +            beganTransaction = TransactionUtil.begin();
>               orderIds = TransactionUtil.doNewTransaction(new Callable<List<String>>() {
>                   public List<String>  call() throws Exception {
>                       List<String>  orderIds = new LinkedList<String>();

Er, really?  This is not the correct fix.  Do you see that 
TransactionUtil.doNewTransaction call?  Do you understand what that 
does(or what it is supposed to do)?

The real problem is in TransactionUtil.doNewTransaction, and it's my fault.

I fixed the root cause in 1343469, then backed out your change in 1343470.