Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0024832Openbravo ERPA. Platformpublic2013-09-25 17:502013-10-21 10:19
vmromanos 
shankarb 
urgentmajoralways
closedfixed 
20Debian 5.0
pi 
3.0MP293.0MP29 
AugustoMauch
Core
No
0024832: EntityPersistenceEventObserver: cascade errors from ProcessBundle are not displayed
Inside an EntityPersistenceEventObserver run a Process through a ProcessBundle. If the process execution raises an exception, the EntityPersistenceEventObserver is unable to show it into the User Interface, and instead it shows the message: "Saving failed. org.openbravo.base.exception.OBException: No request object set"

The cause is in the DalBaseProcess class. At the end of the finally the RequestContext is cleared: RequestContext.clear();
This sentence avoids the EntityPersistenceEventObserver to show the ProcessBundle real exception.
Create an EntityPersistenceEventObserver for any entity.
Run any Process using the ProcessBundle object inside the EntityPersistenceEventObserver, ensuring the execution raises an Exception.

Simplified example:
Inside the EntityPersistenceEventObserver:
try {
      final ProcessBundle bundle = new ProcessBundle(
          SMT001_Constant.PROCESS_UPDATEINVOICEPLAN_CONTRACT_PROCESS_ID, vars)
          .init(new DalConnectionProvider(false));
      bundle.getParams().put(SMT001_Constant.PROCESS_UPDATEINVOICEPLAN_CONTRACT_C_PROJECT_ID_PARAM,
          contract.getId());
      final UpdateInvoicePlan updateInvoicePlanContractProcess = new UpdateInvoicePlan();
      updateInvoicePlanContractProcess.setDoCommit(false);
      updateInvoicePlanContractProcess.execute(bundle);
    } catch (Exception e) {
      throw new OBException(e.getMessage());
    }


Inside the Process (in the example the UpdateInvoicePlan class):
throw new OBException("@PriceListVersionNotFound@. @Product@: " + product.getIdentifier()
            + " @Date@: " + OBDateUtils.formatDate(date));
Remove the RequestContext.clear(); sentence at DalBaseProcess class
No tags attached.
related to defect 00222353.0MP19 closed mtaal OBMessageUtils asumes incorrectly that RequestContext is set 
Issue History
2013-09-25 17:50vmromanosNew Issue
2013-09-25 17:50vmromanosAssigned To => AugustoMauch
2013-09-25 17:50vmromanosModules => Core
2013-09-25 17:50vmromanosTriggers an Emergency Pack => No
2013-09-25 17:51vmromanosRelationship addedrelated to 0022235
2013-09-26 07:57alostaleTarget Version3.0MP28 => 3.0MP29
2013-10-03 09:00shankarbAssigned ToAugustoMauch => shankarb
2013-10-07 20:02mtaalNote Added: 0061599
2013-10-14 19:29shankarbReview Assigned To => AugustoMauch
2013-10-14 19:30hgbotCheckin
2013-10-14 19:30hgbotNote Added: 0061665
2013-10-14 19:30hgbotStatusnew => resolved
2013-10-14 19:30hgbotResolutionopen => fixed
2013-10-14 19:30hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/18f6233c80af03af357e5bdaa7e4d40d81f3fdb1 [^]
2013-10-16 19:47hudsonbotCheckin
2013-10-16 19:47hudsonbotNote Added: 0061751
2013-10-21 10:19AugustoMauchNote Added: 0061813
2013-10-21 10:19AugustoMauchStatusresolved => closed
2013-10-21 10:19AugustoMauchFixed in Version => 3.0MP29

Notes
(0061599)
mtaal   
2013-10-07 20:02   
I think the best approach is to before the try before setting variables secure app, get the current variables secure app
and then restoring that value later at the end.

So something like:
VariablesSecureApp currentVariablesSecureApp = RequestContext.get().getVariableSecureApp();
    RequestContext.get().setVariableSecureApp(processContext.toVars());
try {
...
}
...
      OBContext.setOBContext(currentOBContext);
      RequestContext.get().setVariableSecureApp(currentVariablesSecureApp);
(0061665)
hgbot   
2013-10-14 19:30   
Repository: erp/devel/pi
Changeset: 18f6233c80af03af357e5bdaa7e4d40d81f3fdb1
Author: Shankar Balachandran <shankar.balachandran <at> openbravo.com>
Date: Mon Oct 14 22:54:21 2013 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/18f6233c80af03af357e5bdaa7e4d40d81f3fdb1 [^]

Fixes Issue 0024832: EntityPersistenceEventObserver: cascade errors from ProcessBundle are not displayed

The RequestContext is not cleared to provide the user any errors that is being thrown by the process.

---
M src-test/org/openbravo/test/dal/IssuesTest.java
M src/org/openbravo/service/db/DalBaseProcess.java
---
(0061751)
hudsonbot   
2013-10-16 19:47   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/51315988909a [^]

Maturity status: Test
(0061813)
AugustoMauch   
2013-10-21 10:19   
Code reviewed and verified in pi@cf31b113f28f