Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0029910Openbravo ERPA. Platformpublic2015-05-18 10:302015-11-23 21:17
yogaskarnik 
platform 
normalminorsometimes
closedfixed 
5
3.0PR15Q1 
3.0PR16Q1 
caristu
Core
No
0029910: exporting grid to csv can fail if audit fields are included
Under certain circumstances when trying to export a grid to csv including audit columns it can fail.

When this happens:
* The CSV file contains a single line with:
{"response":{"status":-4,"error":{"message":"Error while exporting a CSV file", "type":"system"}}}
* This exception appears in openbravo.log:
370815 [http-8080-1] ERROR org.openbravo.client.kernel.KernelUtils - Error while exporting a CSV file
org.openbravo.base.exception.OBException: Error while exporting a CSV file
    at org.openbravo.service.datasource.DataSourceServlet$QueryJSONWriterToCSV.<init>(DataSourceServlet.java:493)
...
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ADElement.aDElementTrlList, no session or session was closed
    at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
    at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
    at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
    at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
    at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
    at org.openbravo.client.application.window.OBViewUtil.getLabel(OBViewUtil.java:130)

See steps to reproduce: the problem is OBViewUtil caches audit elements, but initially not their possible translations required for labeling csv columns. Step 6 initalizes those elements but translations only for one of them, steps 8 tries to get label from proxy of a DAL object which session is not longer in the thread.
In an instance with *no* modules in development:
1. Open Sales Order window
2. Restart Tomcat (so JVM caches are restarted also)
3. Login with the same browser used in step 1 (without cleaning its cache)
4. Open Sales Order window (at this point view is not requested because it is cached in browser)
5. Add Created column to grid
6. Export to csv
7. Add Updated column to grid
8. Export to csv
  -> FAILS with error mentioned above
No tags attached.
related to defect 00227643.0MP20 closed alostale cannot open any window 
has duplicate defect 0030289 closed platform Sometimes the export to csv fails 
related to defect 0028477 closed alostale view generation: unneeded queries to trl tables 
log openbravo70.log (19,239) 2015-05-18 10:30
https://issues.openbravo.com/file_download.php?file_id=8097&type=bug
Issue History
2015-05-18 10:30yogaskarnikNew Issue
2015-05-18 10:30yogaskarnikAssigned To => platform
2015-05-18 10:30yogaskarnikFile Added: openbravo70.log
2015-05-18 10:30yogaskarnikModules => Core
2015-05-18 10:30yogaskarnikTriggers an Emergency Pack => No
2015-06-30 17:09caristuRelationship addedhas duplicate 0030289
2015-11-10 15:27alostaleRelationship addedrelated to 0022764
2015-11-10 16:05alostaleReproducibilityunable to reproduce => sometimes
2015-11-10 16:05alostaleSummaryCannot export data from window that has dates (created, updated) in the grid => exporting grid to csv can fail if audit fields are included
2015-11-10 16:05alostaleDescription Updatedbug_revision_view_page.php?rev_id=10137#r10137
2015-11-10 16:05alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=10139#r10139
2015-11-10 16:09alostaleDescription Updatedbug_revision_view_page.php?rev_id=10140#r10140
2015-11-10 16:09alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=10141#r10141
2015-11-10 16:26hgbotCheckin
2015-11-10 16:26hgbotNote Added: 0081659
2015-11-10 16:26hgbotStatusnew => resolved
2015-11-10 16:26hgbotResolutionopen => fixed
2015-11-10 16:26hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/c365fc9d4bd06bc989248419e9bbd6fd98891ea6 [^]
2015-11-10 16:26alostaleReview Assigned To => caristu
2015-11-10 18:29egoitzIssue Monitored: egoitz
2015-11-11 11:36caristuNote Added: 0081695
2015-11-11 11:36caristuStatusresolved => closed
2015-11-11 11:36caristuFixed in Version => 3.0PR16Q1
2015-11-12 18:13alostaleRelationship addedrelated to 0028477
2015-11-23 21:17hudsonbotCheckin
2015-11-23 21:17hudsonbotNote Added: 0082195

Notes
(0081659)
hgbot   
2015-11-10 16:26   
Repository: erp/devel/pi
Changeset: c365fc9d4bd06bc989248419e9bbd6fd98891ea6
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Tue Nov 10 16:26:06 2015 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/c365fc9d4bd06bc989248419e9bbd6fd98891ea6 [^]

fixed bug 29910: exporting grid to csv can fail if audit fields are included

  This error was caused by a partial initialization of audit elements in OBViewUtil,
  when this occured and label for one of these elements was tried to be obtained,
  LazyInitializationException was thrown.

  It has been fixed by forcing complete initialization of the elements and their
  translations.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java
---
(0081695)
caristu   
2015-11-11 11:36   
Code review + tested OK.

Following the Steps To Reproduce, now CSV file is always exported correctly.
(0082195)
hudsonbot   
2015-11-23 21:17   
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/7b56bebaaa88 [^]
Maturity status: Test