2

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 to war (it's present in /WEB-INF/lib folder alongside other libraries, like gson and hibernate
  • 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 anything

  • Adding -Djava.awt.headless=false to VM options - also didn't change a thing, but once caused NullPointerException inside jasperreport library. For testing program - worked in both cases

  • Adding commons-beanutils-1.9.4.jar, commons-digester-2.1.jar, commons-collections4-4.4.jar and commons-loggin-1.2.jar - with no changes

  • Adding jasper-compiler-jdt-5.5.23.jar - this caused a different error, namely NoSuchMethodError for org.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:

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

Miku
  • 567
  • 6
  • 15
  • 1
    **cannot find symbol** is a compilation failure.This means that the classes JREvaluator, JRFillVariable and the package net.sf.jasperreports.engine have not been imported in the code,before referencing them. – glegshot Aug 25 '20 at 18:08

2 Answers2

0

I have figured it out

For some reason in server project libraries used by jasperreport.jar were not loaded, but in the testing project they were (might be due to WildFly, might be due to differences between IntelliJ and NetBeans)

Here is the list of libraries, based on pom.xml file in jasperreport.jar that I have added. Some might not be necessary and the list might not be exhaustive (I basically stopped adding libraries once report started generating) but it's good enough base if someone else runs into this problem:

  • commons-beanutils-1.9.4.jar
  • itext-2.1.7.jar
  • poi-ooxml-4.1.1.jar
  • commons-collections4-4.4.jar
  • jcommon-1.0.23.jar
  • xalan-2.7.2.jar
  • commons-digester-2.1.jar
  • jfreechart-1.0.19.jar
  • xmpcore-5.1.3.jar
  • commons-logging-1.2.jar
  • poi-4.1.1.jar
Miku
  • 567
  • 6
  • 15
0

I had the same problem, my project execute (by jasper library) a Jasper Report.

On my IDE and JBoss server a did not haver problem, but when I deployed over WildFly the problem appears.

I just needed to add jasper-compiler-jdt.jar to the project libraries, and finally works on WildFly.

Mike Aguilar
  • 348
  • 2
  • 3
  • 14