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.jaris added towar(it's present in/WEB-INF/libfolder alongside other libraries, likegsonandhibernatejasperreports-6.13.0.jarcontains 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=trueto VM options - this did not changed anythingAdding
-Djava.awt.headless=falseto VM options - also didn't change a thing, but once causedNullPointerExceptioninsidejasperreportlibrary. For testing program - worked in both casesAdding
commons-beanutils-1.9.4.jar,commons-digester-2.1.jar,commons-collections4-4.4.jarandcommons-loggin-1.2.jar- with no changesAdding
jasper-compiler-jdt-5.5.23.jar- this caused a different error, namelyNoSuchMethodErrorfororg.eclipse.jdt.internal.compiler.ICompilerRequestorand few others. This library however should not be necessary as - from what I understand -jasperreport-6.13.0.jaralready 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