Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to integrate with JasperReports (build.gradle & bnd.bnd files)
I am creating this question/topic in order to share my experience integrating the jasperreports library - I did not find any relating post about how to really make it work.
The main difficult point was to deploy the module without any error. The thrown exceptions were saying that different packages could not be found at runtime. This errors were caused by wrong bnd.bnd file setup. Bellow is the bnd.bnd file content in the final form:
Bundle-Name: PdfModule
Bundle-SymbolicName: PdfModule
Bundle-Version: 1.0.0
Liferay-Configuration-Path: /configuration
Import-Package:\
!antlr*,\
!com.adobe.xmp*,\
!com.github.kklisura*,\
!com.google.zxing*,\
!com.ibm.icu.lang*,\
!com.ibm.icu.util*,\
!groovy.lang*,\
!groovyjarjarasm.asm*,\
!mondrian.*,\
!net.sf.jasperreports.annotations.properties*,\
!net.sf.jasperreports.metadata.properties*,\
!net.sourceforge.barbecue*,\
!org.apache.batik*,\
!org.apache.commons.javaflow*,\
!org.apache.commons.pool2*,\
!org.apache.http*,\
!org.apache.lucene*,\
!org.apache.poi*,\
!org.apache.velocity*,\
!org.codehaus*,\
!org.eclipse.jdt.core.index*,\
!org.eclipse.jdt.core.util*,\
!netscape.ldap*,\
!org.apache.oro*,\
!org.hibernate.query*,\
!org.kohsuke.groovy.sandbox*,\
!org.krysalis.barcode4j*,\
!org.mozilla.javascript*,\
!org.olap4j*,\
!org.springframework*,\
!org.w3c.dom.svg*,\
!org.bouncycastle*,\
*
Include-Resource: @jasperreports-6.16.0.jar,@commons-collections4-4.2.jar,@commons-digester-2.1.jar,@ecj-3.21.0.jar,@castor-xml-1.4.1.jar,@commons-lang3-3.9.jar,@castor-core-1.4.1.jar,@jfreechart-1.0.19.jar,@jcommon-1.0.24.jar,@jackson-databind-2.10.0.jar,@jackson-core-2.10.0.jar,@jackson-annotations-2.10.0.jar,@itext-2.1.7.jar
And bellow, the build.gradle file:
dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs"
// Jasper
compileOnly group: 'net.sf.jasperreports', name: 'jasperreports', version: '6.16.0'
compileOnly group: 'org.apache.commons', name: 'commons-collections4', version: '4.2'
compileOnly group: 'com.lowagie', name: 'itext', version: '2.1.7'
}
It may not be in their best case form, but it will save you a lot of time starting from these.
If you have any suggestions, please do share ! :)
hi Victor
thank you very much for sharing.
i am using liferay 7.4, it cannot work with this setting
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™