Compile JasperReport jrxml file containing a pl sql procedure to jasper file

0

I writing a reporting web application using JasperReports API in Java. The jrxml files used contain a pl/sql stored procedure call as shown below:

<queryString language="plsql">
        <![CDATA[{call pkg_reports.sp_rpt($P{ORACLE_REF_CURSOR},$P{name})}]]>
 </queryString>

I am using the following Java code to generate the report from the jrxml:

conn = initDBConnection(); //DB Connection
params = parseParameters(list); //Parameters for input to Stored Procedure

//Compile .jrxml file to .jasper
JasperReport jasperReport = JasperCompileManager.compileReport(PATH_TO_JRXML_FILE);

//Generate report           
JasperPrint print = JasperFillManager.fillReport(jasperReport, params, conn);

//Generate PDF File
JasperExportManager.exportReportToPdfFile(print, pdfFilePath);
Logger.debug(" Successfully generated PDF file ");

This gives me the error:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'plsql' language.
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:247)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:230)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:218)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:143)

A quick search online gives the solution to creating the reports which contain a pl sql block.

 

URL fileUrl = getClass().getClassLoader().getResource("PATH TO report.jasper");
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(fileUrl);
jasperReport.setProperty( "net.sf.jasperreports.query.executer.factory.plsql"  
                     ,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");
JRProperties.setProperty( JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX+"plsql"
                     ,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");

JasperPrint print = JasperFillManager.fillReport(jasperReport, params, conn);

 

However, the above code block takes a .jasper file as input, not .jrxml.

I am unable to compile the .jrxml file to a .jasper file in the first place, causing the exception above.

I could not find any property to be set into the JasperCompileManager to allow compilation of the said .jrxml file.

Could anyone please suggest a workaround to this issue? Thanks in advance. :-)

 

anibjoshi's picture
Joined: Jul 29 2015 - 4:56am
Last seen: 3 years 12 months ago

Just add

JRProperties.setProperty( JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX+"plsql"
                     ,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");

prior to compile ex:

     JRProperties.setProperty(JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX + "plsql","com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");
 
     JasperCompileManager.compileReportToFile(reportSrcFile, jasperFileName);

 

yucart - 3 years 4 months ago

1 Answer:

0

Just add

JRProperties.setProperty( JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX+"plsql"
                     ,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");

prior to compile ex:

     JRProperties.setProperty(JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX + "plsql","com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");
 
     JasperCompileManager.compileReportToFile(reportSrcFile, jasperFileName);
yucart's picture
2
Joined: Mar 8 2016 - 12:19pm
Last seen: 3 years 4 months ago
Feedback
randomness