Jump to content
Changes to the Jaspersoft community edition download ×

Having trouble compiling reports


2004 IR Help

Recommended Posts

By: Phil - timelord2004

Having trouble compiling reports

2005-02-06 12:45

Hi,

I'm having trouble compiling reports (I have 0.6.4). I tried producing a compiled report by calling JasperCompileManager.compileReport and passing it my .jrxml file. I was missing the Apache Commons Digester package, but after getting that I now get a stack trace stating error at "line 0, column 0".

Can anyone give me a working example? I cannot figure out why I get this error... the only guess is that maybe the JR and Commons.Digester packages are incompatible??

 

Thanks,

Phil

 

 

 

 

 

By: Phil - timelord2004

RE: Having trouble compiling reports

2005-02-11 02:37

Has anyone got any ideas about this? I still can't compile any jrxml files. I have

- jasper reports in my classpath,

- the commons-digester package (as can be seen from the stack trace),

- called System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");

 

Out of desparation I tried also System.setProperty("org.xml.sax.driver", "gnu.xml.aelfred2.XmlReader"); not sure if that's correct...

 

I'm getting desparate! Has anyone got any working sample code they can post? I hope so, surely everyone else needs to do this all the time also ;-)

 

Thanks

 

 

 

 

By: Wendy - wendy_a

RE: Having trouble compiling reports

2005-02-11 06:30

Hi,

 

I had the SAME problem, but now I can compile, fill and execute my report at runtime,

You have to do:

1. Copy the *.jar to CLASSPATH/lib/ext (the files you will need are: conmons-code-1.2.jar, geronimos-spec0j2ee-1.0-M1.jar, itext-1.1.jar, jasperreports-0.6.3.jar, junit-3.8.jar, log4j-1.2.8.jar

2. In you file.java put this:

JasperDesign jDesign = JasperManager.loadXmlDesign("/tmp/FCT_FACTUR.jrxml");

Map parameters = new HashMap();

String factura = new String ("234");

parameters.put("NumFacturP",factura);

JasperReport jReport = JasperManager.compileReport(jDesign);

JasperPrint jPrint = JasperManager.fillReport(jReport, parameters, getConnection());

JasperManager.printReportToPdf(jPrint);

if (jPrint != null) {

JasperViewer.viewReport(jPrint, false);

}

 

I hope that code could help you.

For any questions: wendy@decsacr.com

 

Bye,

 

Wendy.

 

 

 

 

By: Phil - timelord2004

RE: Having trouble compiling reports

2005-02-11 17:22

Thanks very much for your ideas Wendy... I was still having problems, seemed very much like a classpath problem/conflict still.

I removed everything from my classpath (we have MANY 3rd-party packages), then build it up from scratch. Most significantly I upgraded from commons-collections-2.1.1 to 3.1 and commons-beanutils-1.70, and now it all works!

 

So we had some temperamental inter-dependency stuffed somewhere.

 

Thanks

Phil

 

 

 

 

By: Phil - timelord2004

RE: Having trouble compiling reports

2005-02-06 14:10

(Sorry, Line 1 not Line 0...)

Here's the stacktrace when I call compileReport() using the report filename:

 

7/02/2005 11:02:20 org.apache.commons.digester.Digester warning

WARNING: Parse Warning Error at line 1 column 0: URI was not reported to parser for entity [document]

org.xml.sax.SAXParseException: URI was not reported to parser for entity [document]

at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)

at gnu.xml.aelfred2.SAXDriver.startExternalEntity(SAXDriver.java:631)

at gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3358)

at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:159)

at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)

at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)

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

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

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

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

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

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

 

 

We basically get the same error if we pass an InputStream to compileReport():

 

7/02/2005 11:07:00 org.apache.commons.digester.Digester warning

WARNING: Parse Warning Error at line 1 column 0: URI was not reported to parser for entity [document]

org.xml.sax.SAXParseException: URI was not reported to parser for entity [document]

at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)

at gnu.xml.aelfred2.SAXDriver.startExternalEntity(SAXDriver.java:631)

at gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3358)

at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:159)

at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)

at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)

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

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

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

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

 

 

HTH

 

 

 

 

 

By: Alexander Wallace - aows

RE: Having trouble compiling reports

2005-02-12 08:45

i have code to compile at runtime, but it's with jr 6.2, hopefully it is the same...

 

have you tried with a diferent jrxml, a very simple one just to make sure yours has no errors?

 

Here's my code:

 

public static void compileJRXmlFromDbToFile(ServletContext context, String reportId, String destPath) throw

s JRException, Exception {

if (context == null) throw new Exception("Null servlet context");

if (reportId == null || reportId.trim().length() == 0) throw new Exception("Invalid report name");

 

String classPath = context.getRealPath("/WEB-INF/lib/"+Globals.getJasperLibFilename())

+ System.getProperty("path.separator")

+ context.getRealPath("/WEB-INF/lib/"+Globals.getIReportLibFileName())

+ System.getProperty("path.separator")

+ context.getRealPath("/WEB-INF/classes/");

 

// retrieve xml, compile it and save the generated report.

String xml = getJRXmlFromDb(reportId);

if (xml == null) throw new Exception("Report not found");

 

JasperReport jr = compileJRXmlToJasperReport(xml, classPath);

JRSaver.saveObject(jr, destPath+JASPER_REPORT_PREFIX+reportId+JASPER_EXTENSION);

}

 

you can see i' adding jasper lib and irepor to class path via some static var and getting the xml through an external method, just replace that with your stuff...

 

But somehow i doubt this will help... I think you have a different problem, i bet your already doing something very simmilar to this...

 

Good luck...

Link to comment
Share on other sites

  • 7 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Guys, for any issues with parser error and unable to parse the JRXML , please remove the [gnujaxp.jar] from the classpath. i was successful in getting the compilations done.

So thing is that use JfreeChart but dont bring that jar in the classpath. other wise you guys will continue to get errors /warnings

:) :) :)

THIS WAS SOMETHING STRANGE, SO ITS NOT SURELY BECAUSE OF INCOMPATIBLILITY ISSUES ITS LOOKS MORE A ISSUE WITH SAX PARSER OR DRIVER BEING LOADED AND PRECEDENCE OF DRIVER MAYBE USED BY jfREE cHART...

Post edited by: sanjay0522, at: 2007/03/20 07:31

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...