Jump to content
We've recently updated our Privacy Statement, available here ×

Packaging and distributing Jasper Reports, getting file not found error


qb89dragon

Recommended Posts

 Hi all,

Using Jasper Reports 4.0.0 on Ubuntu 10.04 with Java version:

"java version "1.6.0_20"

OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1~10.04.1)

OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode"

I am getting the following error while trying to write a simple test report to a pdf file (using CSV data) and it works just fine in project mode in eclipse.

at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getResourceURI(JRReportSaxParserFactory.java:189) at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:154) at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.configureParser(JRReportSaxParserFactory.java:138) at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:103) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1332) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1307) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:205) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:170) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:154) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

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

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

at java.lang.reflect.Method.invoke(Method.java:616) net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRRuntimeException: Could not find resource net/sf/jasperreports/engine/dtds/jasperreport.xsd

 

However to distribute it to a state where it can be moved around and run on a server, I have tried two things:

I'm trying to package jasper reports as a standalone jar in eclipse by right clicking the project and selecting export. I have tried several configuration options in there to no avail. (The missing file in the error DOES EXIST in the packaged jar file in its correct place).

I have also tried to use jasper reports through pyjasper and jython, and everything works fine in the same manner as before, and runs into the same identical error.

I have tried adding the xsd file to my classpath, along with its containing folder. I have tried packaging the xsd as a seperate jar file and importing it independently to ensure it is present in java, but it still can't be seen when running outside of eclipse. I have also tried running my code with jasper reports 3.7.6 with identical results. The code used in the jython test is completely independent of the java code used when packaging as jar. Both generate the same error. The table and csv data used preview just fine in ireport and the report is being generated with the java code when run from eclipse.

My error is simmilar to the one mentioned in this (unresolved?) forum post http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=55762

I am relatively new to java, so I would be very grateful for any kind of help towards resolving this. Be it my understanding of java or of jasper reports that is to blame. Thanks in advance!



Post Edited by qb89dragon at 02/09/2011 08:08



Post Edited by qb89dragon at 02/09/2011 08:11
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 I have both methods working now (and my understanding of java is a little improved). I had in eclipse added the net folder from the 'build' directory of the jasper download as a linked external folder. Instead it needed the 'dist' jar package in the classpath.

This was the same story for jython, appending jar packages to the system path was not the answer, running java with jython and jasper reports in the classpath made it all work normally.

for other's future reference, the command I worked out to run jasper with jython (ubuntu 10.04) is:

/usr/bin/java -cp /usr/share/java/jython.jar:/usr/share/java/servlet-api-2.4.jar:/usr/share/java/libreadline-java.jar:"<path to jasper reports>/jasperreports-4.0.0/dist/jasperreports-4.0.0.jar":"<path to jasper reports>/jasperreports-4.0.0/lib/*" -Djava.library.path=/usr/lib/jni -Dpython.home=/usr/share/jython -Dpython.path=/usr/lib/site-python -Dpython.cachedir=/home/qb89dragon/.jython-cache -Dpython.console=org.python.util.ReadlineConsole -Dpython.console.readlinelib=Editline org.python.util.jython <jython-program>.py

(this is based off the jython run script)
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...