I am using Jasper Reports in my Grails 3 application to generate PDF files. I had some issue with Jasper Report plugin for Grails. So we are using Jasperreport jars to generate the PDF.
compile 'net.sf.jasperreports:jasperreports:6.2.1'
I created a 'JasperReports' in project level and added all the jrxml and jasper files. In the development environment I use the below way to compile the report.
jasperReport = JasperCompileManager.compileReport('JasperReports/FYF_Report.jrxml')
Everything works fine in development but when the war is generated it is not including the 'JasperReports' folder. I tried adding the folder in conf but it did not work.
Let me know if I am missing any configuration to include the 'JasperReports' folder in war.
I resolved the issue by adding the JasperReports folder in src/main/webapp. Path to access the files will be different in local and Production, So I am getting the real path from context as below
def sc=session.getServletContext()
def reportsPath=sc.getRealPath("/")
jasperReport = JasperCompileManager.compileReport(reportsPath+'JasperReports/FYF_Report.jrxml')
Related
I have created a jasper report using Jaspersoft Studio 6.19.1. This report utilizes a referenced jar file. The report works fine when running it locally. However, I'm getting an error when running the report from the repository. The error is unable to resolve referenced java class. My question what is the correct way to add and configure a jar file to the server?
Thank you
We have a Maven project which has submodules. There is one parent pom.xml
and each and every sub projects are made into a war file. Each and every submodule has unit test cases and reports generated from Jacoco.
The existing reports show unit test coverage of individual modules but we need to provide integration test-wide code coverage on Tomcat. What we did was we installed jacoco agent in Tomcat folder and configured it to to generate jacoco.exec. When I import jacoco.exec using EclEmma plugin we see the code coverage.
Is there any way to generate report from standalone jacoco.exec without source code?
Download Jacoco agent Zip file from the following URL:
https://www.jacoco.org/jacoco/ select the version that suits your needs.
Create folder with suitable name, I have mine located at "C:\jacoco". Extract the contents of the Zip file there.
Open CMD and go to C:\jacoco
Use the following command:
java -jar jacococli.jar report --classfiles path/of/the/class/files path/of/the/.exec file --html html/report/location --name nameOfTheReport
Note:
1. -jar : I have kept jacococli.jar in Jacoco.
2. --classfiles : Path of the compiled java files.
3. Path of the exec file.
4. --name : Name of HTML report Title (Heading)
Java code coverage report will be generated at your mentioned location.
Jacoco .exec files use a very optimised file format that contain compact bit sets of which checkpoints have been executed and which have not been executed, but contain no informations about line numbers.
So, to generate any report, .exec files need to be applied to class files, that contains line numbers as debug informations.
Class files are enough to produce xml reports, while also sources are needed to produce html reports (for the sake of generating html pages with coloured lines).
Most Jacoco tools to generate reports allow you to specify where to find classes and sources to properly generate reports, so if you can download those exec file to a develop machine where there are also classes and sources, you will be able to generate reports.
I have approximately 5 jrxml files and many jsp files in a project.Now i have to integrate jrxml files to a project present in eclipse.
Now, how to integrate jrxml files to eclipse so that it should be directory independant (it should not be like this eg:-D:/dev/tools/jasper files/report11.jrxml)?
The second question is we have to include both .jrxml and .jasper files?
The third question is "if we open the project which is present in eclipse in another person PC by pasting this url (http://192.1.168.201:8080/SalesProject/) in other person PC it should run normally and should run jrxml files and should display the data in different formats (eg:-PDF,DOC,XLS,XLSX)
Where to put them? In a folder that is deployed on server as you do with your jsp, images web-inf ecc.
Do I need both .jrxml and .jasper?, No .jasper is enough (note: naturally in your server code you should not compile the .jrxml files anymore). To make it easier to understand a comparisons with java would be .jrxml = .java and .jasper = .class
Will it work? Sure since they are deployed on the server you only need to figure out how to reference them correctly from your .jsf page (search some one the web or on SO, there are a lot of answers) ...
ServletContext context = request.getServletContext();
String fullPath = context.getRealPath("/WEB-INF/reports/your_report.jasper");
I am using Jasper Reports 5.2.0 and Spring MVC with Maven.
I have done reports using JasperViewer, but suddenly I am getting this error that can't be resolved:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '
net/sf/jasperreports/fonts/pictonic/pictonic.ttf
net/sf/jasperreports/fonts/pictonic/pictonic.svg
net/sf/jasperreports/fonts/pictonic/pictonic.eot
net/sf/jasperreports/fonts/pictonic/pictonic.woff
' is not available to the JVM. See the Javadoc for more details.
Delete the jar extra placed jars in your lib folder it works properly
or use same version jar file in maven dependency and webroot ->lib folder or in class path
For me, in one instance, the problem was with the jasperreports version as I had more that one jasperreports jar in my classpath.
My reports were compiled with jasperreports-5.6.0 and in my classpath jasperreports-4.1.1.jar was also included and accidentally jasperreports-4.1.1.jar was "up" in the Build class path order.
Actually, my eclipse project had jasperreports-5.6.0 as a library jar and this project had another project as "Required projects in the build path" that contained the old version of jasperreports.
I moved the jasperreports-5.6.0 to "Up in the build classpath order" than the old version, and the problem got resolved.
Again, later I removed the project dependency and got the problem resolved as well.
So check, whether you have more than one jasperreports library anyhow; if so, remove the unnecessary duplicate jar.
The Problem is one of the fonts you used in Jasper Reports not installed in the system. The solution is to install all missing fonts. Another alternative is to use only the fonts "Serif" and "San-Serif" which eliminates the need of installing fonts seperately and would even work when the code is moved accross different servers.
I'm using JasperReports 3.7.6 with NetBeans 6.9.1 and iReport 3.7.6. I have a report that uses scriptlets. When I run it from iReport everything is fine because I can tell iReport where to find the .jar file with the scriptlets. When I run that same report from a JSF-2.0 application the fields that rely on the scriptlet are not being populated correctly - i.e. the scriptlet isn't being called. I've tried putting the scriptlet in the project's library folder and I've tried copying the package containing the scriptlet into the project. Neither has worked. I'm not sure how I can get the report to call the scriptlets when it is run from my JSF project. Can anyone shed some light on this for me?
Ugh. What is it with me and rookie mistakes? I have my JSF project pulling the .jasper files from a specific locations. To that end I have my iReport compiling the reports to that particular file location. At some point in the past week I was fiddling with another report and didn't want it to go to the same location as my project reports ... so I changed the compile location in iReport. It was after that when I created all the scriptlet functionality. When I added the scriptlet functionality and compiled the reports, I forgot to change the compile location back to the project report folder. The reports were compiling elsewhere. So my project was using the old versions of the report files. Updating the compile location in iReport and recompiling the reports fixed the issue. The .jar file in my library works fine.