I’ve followed a tutorial on how to use Jasper report in Netbeans IDE at http://developers.sun.com/jsenterprise/reference/techart/jse8/jasper_reports.html
However, I encountered the following problems.
(Please note that when I refer to jasperreport library, I mean my customized library that contains a number of jar files that are necessary to compile and run jasperreport. You can name the library whatever you’d like to.
Feb 15, 2008 4:23:50 PM org.apache.commons.digester.Digester getParser
javax.xml.parsers.ParserConfigurationException: XML document validation is not supported
I am not sure if I understand it correctly. After several goolging attempts, I’ve found that it’s because there are more than one xml parser libraries in the library path of the project running Jasper. As a result, Jasper report uses the wrong xerces.jar path.
From my understanding is that:
- A project contains several tasks relating to XML documents such as parsing text from XML documents and creating Jasper report.
- Developer of the project add other xml parser libraries in addition to the Jasper report library into the project library class path. For example, the developer adds piccolo.jar and jasperreports–version–.jar and other commons jar libraries.
- The problem is that instead of using its own xerces library, the Jasper report uses xerces of the piccolo.jar library. (It may not be correct, but the idea is Jasper uses the wrong library).
- As a results, when executing the program, the error above is generated.
SOLUTION for ERROR #1
The solution to this error is that we need to put jasperreports library in front of piccolo library in the project library class path. To do this in Netbeans IDE 6.0.1, perform the following steps.
- Right click on the project name in the project window
- Click on Properties
- Click on Libraries
- We will see that the jasper library is below piccolo library.
- To fix the error, click on Jasper library and click “Move up” to move the Jasper library to be above other xml parser libraries such as “Piccolo” or “Jdom”.
- Close the project library window, click Run again on the Netbeans IDE.
After I fixed the ERROR#1 above, I get this error#2. The cause of this error is that it requires jdt-compiler–version–.jar library. This library can be found in the “lib” directory under the jasperreports-project.tar.gz.
net.sf.jasperreports.engine.JRException: Error compiling report java source files : /HelloReportWorld_1203118710653_430914.java
SOLUTION for ERROR#2
To fix this error, we will add jdt-compiler-version.jar into the jasper library in the Netbeans IDE. Follow the steps below.
- On the Netbeans IDE, Tools–>Libraries
- Click on “Jasper” on the Libraries window. (Note that “Jasper” is the name of Jasper library that contains jasperreports.jar and other commons-.jar libraries. The name of this library can be arbitrary, depending on developer.)
- Then, click “Add Jar”
- Browse the where the jdt-compiler-version.jar is, and add it to the “Jasper” library.
- Close the library window, and run the program again.
Now, the Jasper report should be generated successfully.
ERROR #3: I receive another error when I try to generate pdf document using:
SOLUTION TO ERROR #3: If anyone gets an error when running jasperreports for generating pdf file, to fix this error you have to add itext.jar library to the Jasper library.
Just for a reference, libraries that I’ve added to the Jasper library are:
- xercesImpl.jar (This library is required for fixing ERROR#1)
- itext-1.3.1.jar (for printing pdf)