TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.06k stars 404 forks source link

With Jasper report 6.20.5, failing runtime for transitive dependencies #383

Closed dnyaneshwarjadhav closed 1 year ago

dnyaneshwarjadhav commented 1 year ago

With old ticket reference : https://github.com/TIBCOSoftware/jasperreports/issues/376

build.gradle

buildscript {
    ext {
        springBootVersion = '3.1.2'
        springCloudVersion='2022.0.4'
    }
    repositories {
        mavenCentral()

        maven {
            url = uri('https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-repo/')
        }

        maven {
            url = uri('https://repo.maven.apache.org/maven2/')
        }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    compileOnly "org.projectlombok:lombok:${lombokVersion}"
    annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
    runtimeOnly 'mysql:mysql-connector-java:8.0.29'
    implementation 'net.sf.jasperreports:jasperreports:6.20.5'
    implementation 'com.github.librepdf:openpdf:1.3.30'

}

While generating report with following line. byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);

With following stacktrace:


java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
    at net.sf.jasperreports.export.pdf.classic.ClassicPdfProducerFactory.createProducer(ClassicPdfProducerFactory.java:44) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at net.sf.jasperreports.engine.export.JRPdfExporter.createPdfProducer(JRPdfExporter.java:902) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at net.sf.jasperreports.engine.export.JRPdfExporter.initExport(JRPdfExporter.java:733) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:694) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at net.sf.jasperreports.engine.JasperExportManager.exportToPdf(JasperExportManager.java:217) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdf(JasperExportManager.java:542) ~[jasperreports-6.20.5.jar:6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e]
    at com.dashboard.service.TestServiceImpl.jasperReport(TestServiceImpl.java:188) ~[main/:na]
    at com.dashboard.DashboardServiceApp.lambda$0(DashboardServiceApp.java:32) ~[main/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:755) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:319) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
    at com.dashboard.DashboardServiceApp.main(DashboardServiceApp.java:26) ~[main/:na]
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    ... 14 common frames omitted

As in above referenced ticket mentioned opendPDF to be removed, but whether it is in or out the error is the same all the time. let me know what should be eliminate in this case.

If I dont include openPDF dependency it is giving me following build time error

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find com.github.librepdf:openpdf:1.3.30.jaspersoft.2.
     Required by:
         project : > net.sf.jasperreports:jasperreports:6.20.5

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
dnyaneshwarjadhav commented 1 year ago

Is this compatible issue with spring boot 3 ? since Jasper-6.20.5 was worked with spring boot 2.6.6

teodord commented 1 year ago

I'm sorry, but we do not have Gradle expertise to help you. As long as you have OpenPDF in the classpath when you run JasperReport PDF export procedure, things should be just fine. The error indicates OpenPDF is not in the classpath when the PDF exporter is called, but that must be some Gradle classpath issue we cannot help you with.