Recently I've been working on report generation with Jasper. I have created a simple program to test it and when running it via IDE it did work fine.
Then I moved the (very short) class to WildFly sever application and despite having the exact same code and library generation fails with cannot find symbol
. Those symbols it cannot find are JREvaluator
, JRFillVariable
as well as packages such as net.sf.jasperreports.engine
In so far I have confirmed that:
- Project builds (meaning those classes are visible for javac, but not jvm)
jasperreports-6.13.0.jar
is added towar
(it's present in/WEB-INF/lib
folder alongside other libraries, likegson
andhibernate
jasperreports-6.13.0.jar
contains the missing classes
It looks to me like the problem doesn't lie in library not being loaded or missing classes (because in testing environment it works), but like something was preventing JBoss class loader from loading those classes
Attempted (and failed) solutions
Clean and Build
Adding
-Djava.awt.headless=true
to VM options - this did not changed anythingAdding
-Djava.awt.headless=false
to VM options - also didn't change a thing, but once causedNullPointerException
insidejasperreport
library. For testing program - worked in both casesAdding
commons-beanutils-1.9.4.jar
,commons-digester-2.1.jar
,commons-collections4-4.4.jar
andcommons-loggin-1.2.jar
- with no changesAdding
jasper-compiler-jdt-5.5.23.jar
- this caused a different error, namelyNoSuchMethodError
fororg.eclipse.jdt.internal.compiler.ICompilerRequestor
and few others. This library however should not be necessary as - from what I understand -jasperreport-6.13.0.jar
already contains it's compiler and separate library for compiler is not required since a long time.
What has not been attempted:
- Forcing the classes to load (http://www.java2s.com/Code/Java/Reflection/Forcethegivenclasstobeloadedfully.htm)
- Dynamically loading jar during Runtime or using custom class loader
Update: after looking at this answer and applying the suggestion the missing class was different. Which suggests that the dependencies inside jasperreport.jar
are not being loaded properly