I’m using NetBeans. I have a simple project, which prints in a fancy format some data sent as arguments.
This is the code that throws an Exception:
JasperDesign design = JRXmlLoader.load("Certificate.jrxml");
JasperReport report = JasperCompileManager.compileReport(design);
JasperPrint print = JasperFillManager.fillReport(report, new HashMap(), new ClientList(args).getClients());
JPanel panel= new JRViewer(print);
These Exceptions are thrown whenever a Jasper class is created.
I also tried System.getProperty(“java.class.path”) and it includes the “jasperreports-5.0.1.jar” file..
What am I doing wrong? I know these Exceptions are thrown whenever a class is available at compile time, but not at runtime.. But the jar is there!
Requested Stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at certificado.Certificado.main(Certificado.java:31)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Java Result: 1
You may be compiling against the Jasper jar ok, but at runtime that jar has its own dependencies, and you should include those too.
According to your stacktrace you need Apache Commons Digester. I would perhaps build using Maven, and let Maven (hopefully) resolve the set of dependencies for you. You can use a Jar search engine to find these dependencies, but they won’t determine matching versions of those jars for you.