1

I am using Java Spring 2.3.2 application to generate pdf files with jasperreports and lowagie:itext. The old lowagie:itext dependancy (2.1.7) works just fine, but when I upgrade it to the latest version (4.2.2), it returns error message saying that it could not find PdfGState class:

18:26:02.169 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfGState] with root cause
java.lang.ClassNotFoundException: com.lowagie.text.pdf.PdfGState

Snipet from build.gradle:

    implementation "net.sf.jasperreports:jasperreports:6.14.0"
    implementation "com.lowagie:itext:4.2.2"

What might be the problem here?

Tambet Tamm
  • 167
  • 1
  • 1
  • 6
  • 1
    This is because no jar files for version `4.2.2` exist. Either use version `2.1.7`, or use iText 5, but then you must also change every `com.lowagie` to `com.itextpdf`. Versions 4.2.0 was an internal tag that was never released, 4.2.1 was released by InProTopia who also hijacked the `com.lowagie` namespace on Maven central, and with 4.2.2 iText Software got the namespace back. I believe that artifact also redirects to a 5.5.x version on Maven Central. – Amedee Van Gasse Aug 03 '20 at 16:29
  • 1
    Other duplicates: https://stackoverflow.com/questions/44160828/errorfailed-to-resolve-com-itextpdfitextpdf4-2-2 https://stackoverflow.com/questions/31386309/itext-version-4-2-1-redirected-in-maven-central-repository https://stackoverflow.com/questions/37740725/how-to-migrate-com-lowagie-itext-form-2-1-7-to-4-2-0 – Amedee Van Gasse Aug 03 '20 at 16:33
  • 1
    And this blog post: https://itextpdf.com/en/blog/technical-notes/my-maven-build-broken-what-should-i-do – Amedee Van Gasse Aug 03 '20 at 16:33

0 Answers0