Jump to content

No query executer factory registered for the 'sql'


shafiqfar

Recommended Posts

Hi,

I'm attempting to embed JasperReports into an Oracle 10g JVM for use within an application.

The classes concerned are all valid and as far as I'm aware, all required classes are loaded into the JVM.

When I try to run a report, I get:

 

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'sql' language.
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:222)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:210)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:165)
    at JasperReportMgr.exec(JasperReportMgr:68)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'sql' language.
    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2919)
    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2945)
    at org.apache.commons.digester.Digester.endElement(Digester.java:1133)
    at net.sf.jasperreports.engine.xml.JRXmlDigester.endElement(JRXmlDigester.java:183)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1647)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:235)
    ... 4 more

This takes place when I attempt to Compile the report.

I have tried the same process with a report that does not have a query in it (a blank report) and it works fine.

I have also tried the workarounds with the class loader documented previously and they don't seem to have any effect on it

I am running verison 3.6.1 by the way - so this is brand new.

Any comments would be much appreciated.

Thanks


Code:
  import net.sf.jasperreports.engine.JasperCompileManager;  import net.sf.jasperreports.engine.JasperReport;  import net.sf.jasperreports.engine.JasperPrint;  import net.sf.jasperreports.engine.JasperFillManager;  import net.sf.jasperreports.engine.JasperExportManager;  import net.sf.jasperreports.engine.JRException;  import net.sf.jasperreports.engine.xml.JRXmlLoader;  import net.sf.jasperreports.engine.design.JasperDesign;  import net.sf.jasperreports.engine.util.JRProperties;    import java.sql.DriverManager;  import java.sql.Connection;  import java.sql.Statement;  import java.sql.ResultSet;  import java.util.HashMap;  import java.io.InputStream;  import java.io.OutputStream;  import java.io.ByteArrayInputStream;  import java.io.ByteArrayOutputStream;    import oracle.sql.BLOB;  import oracle.jdbc.OraclePreparedStatement;   public class JasperReportMgr{      public static void exec (Integer rptID) throws Exception{            try{                System.out.println("--begin--");        System.out.println("rptID: " + rptID.intValue());                  String userName = "RMSREPORT";        String passWord = "RMSREPORT";   /* has to be better way to encrypt the pass */        String url = "jdbc:oracle:thin:@localhost/DEV";        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();        Connection connection = DriverManager.getConnection(url, userName, passWord);        System.out.println("Database connection established");                                int templateID = 0;                HashMap parameters = new HashMap();        Statement statement = connection.createStatement();                ResultSet resultSet = statement.executeQuery("select param_name, param_type, param_value from reportparams where report_id="+rptID.intValue());        while(resultSet.next()){          String param = resultSet.getString("PARAM_NAME");          if(param.equals("TEMPLATE_ID"))            templateID = Integer.parseInt(resultSet.getString("PARAM_VALUE"));          else{            String param_data_type = resultSet.getString("PARAM_TYPE");            if(param_data_type.equals("NUM"))              parameters.put(param, new Integer(resultSet.getString("PARAM_NUM_VALUE")));                             else if(param_data_type.equals("CHAR"))              parameters.put(param, resultSet.getString("PARAM_CHAR_VALUE"));                       /* else if(param_data_type.equals("DATE")) */          }        }                       System.out.println("Created Parameters");               resultSet = statement.executeQuery("select template_content from jrxmltemplates where template_id = " + templateID);        resultSet.next();        InputStream templateAsInputStream = (resultSet.getBlob(1)).getBinaryStream();               System.out.println("Got template stream");        ByteArrayOutputStream reportAsOutputStream = new ByteArrayOutputStream();        System.out.println("Trying2");        Thread.currentThread().setContextClassLoader(JasperDesign.class.getClassLoader());        JasperCompileManager.compileReportToStream(templateAsInputStream, reportAsOutputStream);        byte reportAsByteArray[] = reportAsOutputStream.toByteArray();        System.out.println("Compile report, len: " + reportAsByteArray.length);        ByteArrayInputStream reportAsInputStream = new ByteArrayInputStream(reportAsByteArray);                ByteArrayOutputStream fillReportAsOutputStream = new ByteArrayOutputStream();        System.out.println("attempting fill");        JasperFillManager.fillReportToStream(reportAsInputStream, fillReportAsOutputStream, parameters, connection);        System.out.println("Fill report with specified parameters");        byte fillReportAsByteArray[] = fillReportAsOutputStream.toByteArray();        ByteArrayInputStream fillReportAsInputStream = new ByteArrayInputStream(fillReportAsByteArray);        ByteArrayOutputStream pdfReportAsOutputStream = new ByteArrayOutputStream();        JasperExportManager.exportReportToPdfStream(fillReportAsInputStream, pdfReportAsOutputStream);        byte pdfReportAsByteArray[] = pdfReportAsOutputStream.toByteArray();        System.out.println("Report exported to PDF " + pdfReportAsByteArray.length);        BLOB tempBlob = BLOB.createTemporary(connection, false, BLOB.DURATION_SESSION);        tempBlob.putBytes(1, pdfReportAsByteArray);        System.out.println("Wrote PDF to temporary BLOB");                OraclePreparedStatement preparedStatement = (OraclePreparedStatement)connection.prepareStatement("insert into pdfreports (GEN_PDF) values(?)");                preparedStatement.setBlob(1, tempBlob);        preparedStatement.execute();        preparedStatement.close();        System.out.println("Inserted temporary BLOB to PDFREPORTS table");        System.out.println("--end--");      }      catch(ClassCastException e){        System.out.println(e);           }      catch(JRException e){        e.printStackTrace();      }      catch(Exception e){        System.out.println(e);        throw e;              }                        }}

Post Edited by shafiqfar at 11/08/2009 13:28
Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 13
  • Created
  • Last Reply

Top Posters In This Topic

  • 5 months later...

Here's my code.

It works fine when I use it locally.

It crashes on line: JasperReport jasperReport = JasperCompileManager.compileReport(is);

when I run it after embedding to sybase.

 

Regards,

PiotrN

Code:


Post Edited by piotrn at 05/12/2010 13:39
Link to comment
Share on other sites

Hi,

I'm affraid I can't log from JR on Sybase enviroment, when I load my jars to database, all properies files are ignored.

 

Here's full stack trace from db logs:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'SQL' language.

    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:245)

    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228)

    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:199)

    at JRepPro.JRepUtil.runReport(JRepUtil.java:60)

    at JRepPro.JRepUtil.main(JRepUtil.java:119)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at ianywhere.sa.jvm.SAJvm.executeMethod(SAJvm.java:1108)

    at ianywhere.sa.jvm.SAJvm.run(SAJvm.java:262)

Caused by: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'SQL' language.

    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2919)

    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2945)

    at org.apache.commons.digester.Digester.endElement(Digester.java:1133)

    at net.sf.jasperreports.engine.xml.JRXmlDigester.endElement(JRXmlDigester.java:183)

    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)

    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:821)

    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)

    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)

    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

    at org.apache.commons.digester.Digester.parse(Digester.java:1647)

    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:241)

    ... 11 more

Caused by: net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'SQL' language.

    at net.sf.jasperreports.engine.util.JRQueryExecuterUtils.getQueryExecuterFactory(JRQueryExecuterUtils.java:63)

    at net.sf.jasperreports.engine.design.JRDesignDataset.queryLanguageChanged(JRDesignDataset.java:1004)

    at net.sf.jasperreports.engine.design.JRDesignDataset.setQuery(JRDesignDataset.java:549)

    at net.sf.jasperreports.engine.design.JasperDesign.setQuery(JasperDesign.java:916)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:281)

    at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:216)

    at org.apache.commons.digester.Rule.end(Rule.java:230)

    at org.apache.commons.digester.Digester.endElement(Digester.java:1130)

 

 

PiotrN

Link to comment
Share on other sites

piotrn
Wrote:

I'm affraid I can't log from JR on Sybase enviroment, when I load my jars to database, all properies files are ignored.

That just might be the cause of the bug.  The built-in query executers are internally registered via a property file located inside the JR jar, namely jasperreports_extension.properties.  If JR fails to find that resource in the Sybase environment, the query executers (incl. the SQL one) will not be available.

Is this a documented Sybase JRE limitation?

Link to comment
Share on other sites

lucianc
Wrote:

That just might be the cause of the bug.  The built-in query executers are internally registered via a property file located inside the JR jar, namely jasperreports_extension.properties.  If JR fails to find that resource in the Sybase environment, the query executers (incl. the SQL one) will not be available.

Is this a documented Sybase JRE limitation?

I haven't found anyting about problems with propreties files on installing jars to sybase enviroment, but I think that may be it. I've notticed warnings from log4j that appear when there's no properties, and there is one in my jar and it is used when I run my jar in eclipse or in console. That's why I think it was ignored, and so are probobly  JR properties.

Anyway I've managed to load my classes to sybase's classpath and I can use them now without installing them to the enviroment and everything works fine :) well maybe except report viewer which crashes my db after closingh it :)  but that's prblem with sybase and JVM I think.

 

Thanks for your time.

PiotrN

Link to comment
Share on other sites

lucianc
Wrote:

That just might be the cause of the bug.  The built-in query executers are internally registered via a property file located inside the JR jar, namely jasperreports_extension.properties.  If JR fails to find that resource in the Sybase environment, the query executers (incl. the SQL one) will not be available.

Is this a documented Sybase JRE limitation?

I haven't found anyting about problems with propreties files on installing jars to sybase enviroment, but I think that may be it. I've notticed warnings from log4j that appear when there's no properties, and there is one in my jar and it is used when I run my jar in eclipse or in console. That's why I think it was ignored, and so are probobly  JR properties.

Anyway I've managed to load my classes to sybase's classpath and I can use them now without installing them to the enviroment and everything works fine :) well maybe except report viewer which crashes my db after closingh it :)  but that's prblem with sybase and JVM I think.

 

Thanks for your time.

PiotrN

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...