TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.02k stars 394 forks source link

7.0.0. - SQLException: Enlisted connection used without active transaction #462

Closed SATISHEEEK closed 1 month ago

SATISHEEEK commented 1 month ago

Dear Jasper devs, I am sorry to bother you again, but this whole migration has been huge challenge for us and I need your help once again... :(

We're getting a following SQLException while trying to execute a report.

This combination used to work fine with Quarkus2 + Jasper 6, unfortunately with Quarkus 3 + Jasper 7 we're getting an issue with an active transaction

Thank you for any hint!

log:

2024-07-22T21:24:13.597381608Z executor-thread-1 23 2024-07-22 23:24:13.558  ERROR net.sf.jasperreports.engine.fill.JRFillSubreport Fill 1: exception: net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query:
2024-07-22T21:24:13.597462370Z 
2024-07-22T21:24:13.597475177Z SELECT
2024-07-22T21:24:13.597486237Z     *
2024-07-22T21:24:13.597502662Z FROM
2024-07-22T21:24:13.597519521Z     MY_TABLE
2024-07-22T21:24:13.597530077Z ORDER BY
2024-07-22T21:24:13.597538483Z     col
2024-07-22T21:24:13.597547363Z 
2024-07-22T21:24:13.597555636Z 
2024-07-22T21:24:13.597574220Z  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:555)
2024-07-22T21:24:13.597810783Z  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:299)
2024-07-22T21:24:13.598088743Z  at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1317)
2024-07-22T21:24:13.598244727Z  at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:767)
2024-07-22T21:24:13.598340997Z  at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:465)
2024-07-22T21:24:13.598391111Z  at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:585)
2024-07-22T21:24:13.598464565Z  at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:416)
2024-07-22T21:24:13.598525214Z  at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:827)
2024-07-22T21:24:13.598583947Z  at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:61)
2024-07-22T21:24:13.598621143Z  at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
2024-07-22T21:24:13.598716311Z  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
2024-07-22T21:24:13.598803387Z  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
2024-07-22T21:24:13.598913843Z  at java.base/java.lang.Thread.run(Thread.java:840)
2024-07-22T21:24:13.599023284Z Caused by: java.sql.SQLException: Enlisted connection used without active transaction
2024-07-22T21:24:13.599110173Z  at io.agroal.pool.ConnectionHandler.verifyEnlistment(ConnectionHandler.java:398)
2024-07-22T21:24:13.599149982Z  at io.agroal.pool.wrapper.ConnectionWrapper.getMetaData(ConnectionWrapper.java:452)
2024-07-22T21:24:13.599212173Z  at net.sf.jasperreports.engine.query.OracleProcedureCallHandler.isOracle(OracleProcedureCallHandler.java:72)
2024-07-22T21:24:13.599341106Z  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.isProcedureCall(JRJdbcQueryExecuter.java:566)
2024-07-22T21:24:13.599481640Z  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:389)
2024-07-22T21:24:13.599597852Z  ... 12 more
teodord commented 1 month ago

Try to minimize the number of moving parts. You seem to perform several upgrades at the same time. Maybe you should attempt a step by step upgrade approach with only one upgrade at a time, to see which upgrade introduces the problem.

I hope this helps. Teodor

SATISHEEEK commented 1 month ago

Dear @teodord, thank you for your response. Unfortunately I have been able to isolate the problem. It's been related to Quarkus update, but the transaction is lost once it enters Jasper engine.

I did notice that JasperFillManager.fillReport() is a static method, but calling fill method like this unfortunately doesn't help either:

JasperFillManager manager = JasperFillManager.getInstance ( DefaultJasperReportsContext.getInstance() );
return manager.fill(reportFile, parameters, con);
teodord commented 1 month ago

We did not change anything in our JDBC query executers recently.

SATISHEEEK commented 1 month ago

@teodord Thank you for fast reply. I'll keep digging in Quarkus changes to see why we're loosing the transaction in the process..

would you be, please, that kind and had a look at my follow-up question in https://github.com/TIBCOSoftware/jasperreports/issues/460

Thank you!

dadza commented 1 month ago

The exception is thrown from a subreport execution, which means that you either have a subreport or a table in your report.

Subreports and tables are rendered on separate threads, which might explain the exception since there seem to be similar errors reported here