Dependency error in jasper-reports from itext

Laura Abad Avilés picture Laura Abad Avilés · Jul 9, 2015 · Viewed 36.7k times · Source

From yesterday I have problems compiling with maven because of iText jar. My project has a dependency of jasperreports-2.0.1 that depends on itext-1.02b or higher.

<dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>[1.02b,)</version>
    <scope>compile</scope>
</dependency>

That is the log error in maven:

Failed to collect dependencies for [jasperreports:jasperreports:jar:2.0.1 (compile)]: Failed to read artifact descriptor for com.lowagie:itext:jar:4.2.2: Could not transfer artifact com.itextpdf:itextpdf:pom:4.2.2 from/to jaspersoft (http://www.jasperforge.org/maven2): Access denied to http://www.jasperforge.org/maven2/com/itextpdf/itextpdf/4.2.2/itextpdf-4.2.2.pom. Error code 403, Forbidden -> [Help 1] 

I see here a comment from Amedee Van Gasse that says something about a 4.2.2 version with no jar.

Why does the 1.02b version attach to 4.2.2?

Edit: Jasper-reports uses an open version range:

[1.02b,)

This range says to maven to take the library latest version.

With the update from iText adding new version Pom with no jar and editting the maven-metadata of maven-central to that no-jar version crashes the compilation to all jar depending form latest com.lowagie library.

Updating locally your maven-metadata-central.xml (and other metadata if your company has it's own nexus.public) from ...m2\repository\com\lowagie\itext to that works. Temporally solucion until iText updates the metadata or ALL companies that has dependencies for it's latest version updates it's pom

<metadata modelVersion="1.1.0">
  <groupId>com.lowagie</groupId>
  <artifactId>itext</artifactId>
  <versioning>
    <latest>4.2.1</latest>
    <release>4.2.1</release>
    <versions>
      <version>0.99</version>
      <version>1.1.4</version>
      <version>1.02b</version>
      <version>1.2.3</version>
      <version>1.3</version>
      <version>1.3.1</version>
      <version>1.4</version>
      <version>1.4.8</version>
      <version>2.0.1</version>
      <version>2.0.6</version>
      <version>2.0.7</version>
      <version>2.0.8</version>
      <version>2.1.0</version>
      <version>2.1.2</version>
      <version>2.1.3</version>
      <version>2.1.4</version>
      <version>2.1.5</version>
      <version>2.1.7</version>
      <version>4.2.0</version>
      <version>4.2.1</version>
    </versions>
    <lastUpdated>20150709153501</lastUpdated>
  </versioning>
</metadata>

Answer

Amedee Van Gasse picture Amedee Van Gasse · Jul 14, 2015

A much simpler solution may be to upgrade to a newer version of jasperreports. Version 6.1.0 has this dependency on iText:

<dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>2.1.7.js2</version>
    <scope>compile</scope>
</dependency>

No more "floating" dependency on iText, and it's a version that's custom made for jasperreports!

See http://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.1.0 for the complete pom.xml.