Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0048672Openbravo ERPZ. Otherspublic2022-01-21 22:102022-03-07 11:29
ivazquez 
caristu 
highmajoralways
closedfixed 
5
PR21Q2.3 
PR22Q1.1PR22Q1.1 
Core
Production - Confirmed Stable
2018-09-25
3.0PR18Q4
https://code.openbravo.com/erp/devel/pi/rev/8a73e458127f7a40f4db9fc8583db06798e0856e [^]
No
0048672: Some process definition reports stop working after upgrading from 18Q3 to 21Q2.3
After an upgrade to version 21Q2.3 it was reported that a problem occurred when trying to generate process definition reports that make use of some org.openbravo.erpCommon.utility.Utility methods (that use DAL internally) in the header and also have a subreport executing a query.

The error displayed by the stacktrace is as follows:
Caused by: java.sql.SQLException: PooledConnection has already been closed.

To clarify that in Openbravos.properties the following configuration is found this way:
db.externalPoolClassName=org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool

Related issue: https://issues.openbravo.com/view.php?id=47943 [^]
1.- Download and assemble a pristine in version 21Q2.3
2.- Install the module provided by the customer attached in the issue (which only has the process definition and the jaspers).
3.- Go to "Print Product" and select a product.
4.- Click on the button "Export to PDF".

Returns the following error:
net.sf.jasperreports.engine.JRException: Error preparing the statement to execute the report query.

And in the logs you can see the error mentioned above
No tags attached.
blocks defect 0048465 closed caristu Some process definition reports stop working after upgrading from 18Q3 to 21Q2.3 
Issue History
2022-02-25 10:12caristuTypedefect => backport
2022-02-25 10:12caristuTarget Version => PR22Q1.1
2022-03-01 18:18hgbotNote Added: 0135371
2022-03-07 11:29hgbotResolutionopen => fixed
2022-03-07 11:29hgbotStatusscheduled => closed
2022-03-07 11:29hgbotNote Added: 0135491
2022-03-07 11:29hgbotFixed in Version => PR22Q1.1
2022-03-07 11:29hgbotNote Added: 0135492

Notes
(0135371)
hgbot   
2022-03-01 18:18   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/534 [^]
(0135491)
hgbot   
2022-03-07 11:29   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/534 [^]
(0135492)
hgbot   
2022-03-07 11:29   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 66566a47919c6278d1c0006926bd81356ddb1fb0
Author: Carlos Aristu <carlos.aristu@openbravo.com>
Date: 02-03-2022 08:26:55
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/66566a47919c6278d1c0006926bd81356ddb1fb0 [^]

fixes BUG-48672: manage the DAL connection of the subreports

  Jasper subreports are filled with a multi-threading mechanism. In case
the threads use DAL to retrieve any information (for example an image)
we must ensure that the DAL connection is closed to prevent connection
leaks.

  For this reason, most of the Utility class methods are closing the
connection on finish. But at the same time this can cause problems in
case the DAL connection is reused both in the header and in the
subreport query. In that case if the header closes the DAL connection
through the Utility method, then the subreport will not be able to
execute the query because the connection is already closed.

  To fix this problems, two actions are being taken:

  - We provide our own subreport runner factory to ensure that the
threads used to fill the subreports close the DAL connections when they
are finished.

  - The Utility methods are no longer closing the DAL connection, because
this not needed anymore.

---
A src/org/openbravo/dal/core/DalThreadCleaner.java
A src/org/openbravo/report/jasper/SubreportRunner.java
A src/org/openbravo/report/jasper/SubreportRunnerFactory.java
M src/org/openbravo/dal/core/DalThreadHandler.java
M src/org/openbravo/erpCommon/utility/Utility.java
M src/org/openbravo/erpReports/jasperreports.properties
---