Jump to content
JasperReports Library 7.0 is now available ×

shafiqfar

Members
  • Posts

    1
  • Joined

  • Last visited

shafiqfar's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. 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
×
×
  • Create New...