Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0048673Openbravo ERPZ. Otherspublic2022-01-21 22:102022-03-07 11:27
ivazquez 
caristu 
highmajoralways
closedfixed 
5
PR21Q2.3 
PR21Q4.4PR21Q4.4 
Core
Production - Confirmed Stable
2018-09-25
3.0PR18Q4
https://code.openbravo.com/erp/devel/pi/rev/8a73e458127f7a40f4db9fc8583db06798e0856e [^]
No
0048673: 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 => PR21Q4.4
2022-03-01 18:14hgbotNote Added: 0135370
2022-03-07 11:27hgbotResolutionopen => fixed
2022-03-07 11:27hgbotStatusscheduled => closed
2022-03-07 11:27hgbotNote Added: 0135489
2022-03-07 11:27hgbotFixed in Version => PR21Q4.4
2022-03-07 11:27hgbotNote Added: 0135490

Notes
(0135370)
hgbot   
2022-03-01 18:14   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/533 [^]
(0135489)
hgbot   
2022-03-07 11:27   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/533 [^]
(0135490)
hgbot   
2022-03-07 11:27   
Directly closing issue as related merge request is already approved.

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

fixes BUG-48673: 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
---