I’ve managed to use Jasper report template in my application to display results as pdf. This works fine on my development machine, but get errors when I want to run the report on the production machine. I use a UberJar as deployment option and host it on a Ubuntu machine with Tomcat application server.
A snippet of the error:
com.haulmont.reports.exception.ReportingException: Error formatting jasper report: Errors were encountered when compiling report expressions class file: /Quote_1528711039046_99954.java:4: error: package net.sf.jasperreports.engine does not exist import net.sf.jasperreports.engine.*; ^ /Quote_1528711039046_99954.java:5: error: package net.sf.jasperreports.engine.fill does not exist import net.sf.jasperreports.engine.fill.*; ^ /Quote_1528711039046_99954.java:18: error: cannot find symbol public class Quote_1528711039046_99954 extends JREvaluator
It seems that I’m missing a dependency, but are not sure how to add it to the application server?
Hi,
We have investigated the problem and found out that the user should manually add the jars:
Copy jasperreports-.jar and yarg-.jar to the directory from where the uberJar is launched.
Create the “jasperreports,propeties” file in this folder
Put the following string to the file (define versions of your libraries) net.sf.jasperreports.compiler.classpath = jasperreports-6.4.1.jar;yarg-2.0.14.jar
It has been some time when I have raised this issue but like to revisit it please.
Thank you for the suggestion and also fix that was noted but I’m still struggling to get the deployed Jasper Template executed. I’m using Docker and UberJar as deployment options and included the 3 files as per recommendation. I can also confirm that the files did transfer to the docker machine along with the app.jar
However, if i want to preview my report from the application, I still get the error.
Do I need to specify somewhere in Cuba to include the jasperreports.properties, or do you perhaps have a sample project that I can test please?
You do not need to specify anything in Cuba, it should work if you placed jars and created jasperreports.properties file with names of placed jars. Does the problem occurs only if you use Docker?
The problem is different (Linux) environment, try use colon instead of semicolon.
My working solution is: net.sf.jasperreports.compiler.classpath = ./jasperreports-6.9.0.jar:./yarg-2.2.6.jar
Since all necessary classes of jasperreports-6.9.0.jar, yarg-2.2.6.jar, jasperreports-fonts-6.8.0.jar already present in uberJar, there is more convenient way to fix jasper:
Add 'org.eclipse.jdt.core.compiler:ecj:4.4.2' dependency to coreModule at build.gradle. At this moment, by default, when using uberJar, built as described in documentation, net.sf.jasperreports.engine.design.JRJavacCompiler used for compiling reports. After providing org.eclipse.jdt.core.compiler:ecj, jasper automaticly uses net.sf.jasperreports.engine.design.JRJdtCompiler, which is much faster.
For using jasperreports-fonts extension, it’s possible to copy jasperreports_extension.properties from jasperreports-fonts-6.8.0.jar to root of src folder of core module.
It works fine in docker with just one uber jar.
The most valueable benefit of this configuration is the ability to call project’s classes directly from JRXML template, which is not possible in case of using net.sf.jasperreports.engine.design.JRJavacCompiler, since project classes packed in uber jar.