21

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>
Joris Schellekens
  • 7,482
  • 1
  • 18
  • 47
Laura Abad Avilés
  • 498
  • 1
  • 5
  • 13
  • The iText version you are using dates from [February 2004](http://itextpdf.com/changelog/10). That's 11 and a half years ago. It's a miracle you were able to use it for so long without an upgrade... – Bruno Lowagie Jul 09 '15 at 10:25
  • Yes, the project is really old, but I can't update because is a commercial one, but I say you that it still works, after yesterday. Now we can't compile any release from any environment and is imposible to do deployments. Big issue. – Laura Abad Avilés Jul 09 '15 at 10:29
  • Why don't you fix the dependency so that it sticks to a single version? If you decide you never want to upgrade, you should also tell Maven that you never want to upgrade. – Bruno Lowagie Jul 09 '15 at 10:35
  • I don't need itext, jasperreports has the dependecy. The mistery I have is that in jasperreports pom yo can see the code I write, but maven tries to download 4.2.2 jar not 1.02b that I have in my M2_REPO – Laura Abad Avilés Jul 09 '15 at 10:42
  • If you don't need iText, but jasper-reports, then you are using the wrong tag. You should tag this question as a Jasper-Reports question. – Bruno Lowagie Jul 09 '15 at 10:47
  • I think I have correct tag, because itext references is what fails, not jasperreports. If 1 day ago someone from Itext sais this "iText 4.2.2 is now on Maven Central, sync to other Maven servers will automatically happen in the following hours and days: search.maven.org/…." and then maven fails compiling because a missing reference from 4.2.2 is because something happens with Itext – Laura Abad Avilés Jul 09 '15 at 10:49
  • OK. If you say it's an iText problem, that's your right. But it is not an iText Group problem. iText Group has made it very clear (for many years now) that all versions prior to iText 5 are no longer supported. This means that you're on your own. I don't understand why you contact me personally on Twitter. I have distantiated myself from the old iText many years ago. – Bruno Lowagie Jul 09 '15 at 10:54
  • I'm sorry if I troubled you. You say that is'nt iText Group problem but someone (that I supose from Itext in my ignorance) updates something not supported and crashes it, and stops work from all my team. I saw in Itext page that if I like any response I have to post here. I text you in twitter because you answer in many questions from Itext AND beacuse your surname is Lowaige, the same that I'm writting in google constatly from yesterday trying to solve this. Forther more, I'm not good english writter and maybe it causes some rude words, really sorry for that – Laura Abad Avilés Jul 09 '15 at 11:13
  • Yes, I down-voted that aswer because I think it isn't a good answer, I understand perfectly why people links Itext with Lowagie, but don't use it as a point to don't answer me. I'm newbie here, registered today and can't cause anything in your reputation marks. Thanks for the 11 years of com.lowagie.itext – Laura Abad Avilés Jul 09 '15 at 11:38
  • What is wrong with that answer? It explains that I am a *person* named Lowagie. Incidentally, my name got tangled up in a *product* named iText and and that has almost caused [a personal crisis in 2008](http://www.sramanamitra.com/2015/04/30/bootstrapping-from-belgium-itext-ceo-bruno-lowagie-part-4/). People who down vote that question don't understand what they are down voting. – Bruno Lowagie Jul 09 '15 at 11:55
  • Agree that I don't understand totally what I'm down-voting because I don't know your life, I only know your product from 2 days ago (even now I'm not totally sure what is for) and I see a (in my opinion) good question and an (in my unknowledge) egocentric answer. I apologyze. Now that we know the problem (2 answers down) can Itext Group update maven-metadata again to a latest release that has .jar? Please – Laura Abad Avilés Jul 09 '15 at 12:29
  • No, iText Group can't do that and won't do that. For more info, contact iText Group. – Bruno Lowagie Jul 09 '15 at 12:32
  • Posting here I'm [contacting](http://itextpdf.com/contact) with Itext. Do you know who have permission to update de metadata in maven repository? – Laura Abad Avilés Jul 09 '15 at 12:43
  • Posting here is *not* the same as contacting with iText Group NV. Posting here brings you in contact with iText developers, among others the original developer of iText, but that is *not* the same as contacting iText. – Bruno Lowagie Jul 09 '15 at 13:09
  • 2
    Who has permission to update the metadata in Maven Central for com.lowagie and com.itextpdf: members of the development team at iText Group NV. – Amedee Van Gasse Jul 09 '15 at 13:57
  • The metadata in Maven Central has been updated. The artifact com.lowagie:itext:jar:4.2.2 now redirects to the existing artifact com.itextpdf:itextpdf:jar:5.5.6. Please allow a couple of hours for repositories to sync before the update appears in Maven Central Search, and you may need to force refresh your local Maven cache. (I simply deleted my local ~/.m2 folder - after that, my maven 3.0.5 correctly got the relocated artifact) – Amedee Van Gasse Jul 10 '15 at 08:43

10 Answers10

17

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.

Amedee Van Gasse
  • 6,088
  • 3
  • 41
  • 73
  • 1
    The patched iText version is not available from Maven repository anymore... – doublep Oct 12 '16 at 10:57
  • You should contact Jasper Reports, it is their responsibility to have a correct dependency in their POM. Keep in mind that only iText Software is allowed to put `com.lowagie` artifacts on Maven, and we never uploaded anything with a `.js` extension. I don't know who put it there in the first place and I don't know why it's not there any more. As a workaround, you can try with iText `2.1.7`. – Amedee Van Gasse Oct 12 '16 at 11:06
  • you can review the maven repo https://mvnrepository.com/artifact/com.lowagie/itext/2.1.7 The version is 2.1.7 now, not 2.1.7.js2 – yecid Nov 16 '16 at 15:56
  • 1
    @yecid The version of `com.lowagie` iText on Maven Central has always been `2.1.7`, I don't understand your comment. It's Jasper Reports that is responsible for their own dependency management, or not? – Amedee Van Gasse Dec 15 '16 at 08:43
  • The version name has not the '.js2' suffix now – yecid Jan 13 '17 at 05:25
  • 2
    That is unfortunate. Take it up with Jasper Reports or use one of the other solutions. – Amedee Van Gasse Jan 13 '17 at 05:55
13

The problem is indeed in the POM of jasper-reports:

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

Jasper-reports distributes a (modified) build of iText 2.1.7 since at least November 2012 (if memory serves me well), so if your version of jasper-reports still has a dependency on 1.02b and up, it must be a very old version.

The jasper-reports dependency on iText should be changed to:

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

Or just:

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

This relates to this question: How do I tell Maven to use the latest version of a dependency? That page is riddled with cautions about always using the latest version for your dependencies. It reduces reproducibility of your builds.

2.1.7 was the last version of iText released by the company iText Group NV (or its legal predecessor), with the com.lowagie groupId. The next version of iText, released by the company iText Group NV, was version 5.0.0, with the com.itextpdf groupId, which means it's binary incompatible with your current code. There's also the matter of a license change to AGPL, but that is outside the scope of StackOverflow, I want to restrict my answer to the technical matters.

Any other versions of iText between 2.1.7 and 5.0.0, like 4.2.0 and 4.2.1, are forks by other companies. According to Apache's Guide to uploading artifacts to the Central Repository (https://maven.apache.org/guides/mini/guide-central-repository-upload.html), those companies should have used a different groupId, as the page clearly states in their FAQ:

I have a patched version of the foo project developed at foo.com, what groupId should I use? When you patch / modify a third party project, that patched version becomes your project and therefore should be distributed under a groupId you control as any project you would have developed, never under com.foo. See above considerations about groupId.

TL;DR If you don't want to change your code, tell your Maven to only get iText 2.1.7.

Joris Schellekens
  • 7,482
  • 1
  • 18
  • 47
Amedee Van Gasse
  • 6,088
  • 3
  • 41
  • 73
  • Hi, if the latest iText version from iText is 2.1.7. Why you update the maven-metadata to 4.2.2? I'm agree with you if you like to say that 2.1.7 is the latest version of com.lowagie and update to that because you have all rights about that. In fact, updating the latest version to 4.2.2 crashes all malformed dependencies from other .jar (like jasperreports) and is not necessary because you say iText Group legal jar for com.lowagie goes to 2.1.7. Do your company that error only for free publicity? – Laura Abad Avilés Jul 10 '15 at 06:35
  • If you examine the 4.2.2 POM, you will see that it has a section, redirecting from com.lowagie to com.itextpdf. Ideally, such a POM should have been online at the same iText 5.0.0 was released, in 2009. Unfortunately that didn't happen, and this situation was only recently corrected. I don't know why your Maven doesn't pick up that tag, it should. More information about relocation at http://stackoverflow.com/questions/28881819/maven-pom-relocation – Amedee Van Gasse Jul 10 '15 at 07:05
  • 1
    It does, my maven see the relocation, but goes to itextpdf:itextpdf:pom:4.2.2 and there is no jar, you can see it in mave log error in the original question. Do you say that problem is recently corrected? Do you attach 4.2.2 jar in the new group id? – Laura Abad Avilés Jul 10 '15 at 07:17
  • 1
    OK, this is useful feedback, thank you! That's a situation I can fix, I need to upload another POM that redirects to a itextpdf:itextpdf:pom version that actually exists, like 5.5.6. That way you will still get an error in your build, because of the binary incompatibility, but at least your Maven won't complain. – Amedee Van Gasse Jul 10 '15 at 07:21
  • I have updated the POM on Maven Central. I deleted my local maven cache and created a test project with dependency on itext 4.2.2. Maven gave this warning but the build did not fail (itext wasn't actually used in the test project): [WARNING] The artifact com.lowagie:itext:jar:4.2.2 has been relocated to com.itextpdf:itextpdf:jar:5.5.6 – Amedee Van Gasse Jul 10 '15 at 08:12
10

I'm using gradle and for the current version 6.8.2 I got the following build error:
> Could not find com.lowagie:itext:2.1.7.js6

So I added http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/ as repository and now it works.

repositories {
    mavenCentral()
    maven { url "http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/" }
}

dependencies {
    compile 'net.sf.jasperreports:jasperreports:6.8.0'
}
das Keks
  • 2,933
  • 3
  • 27
  • 48
  • Is the jaspersoft.jfrog.io listed as an official repo from JasperSoft or somehow vetted by jfrog? – Freiheit Jul 30 '19 at 22:03
  • JFrog is listed as a sponsor on the official Jaspersoft homepage. https://community.jaspersoft.com/wiki/sponsors I think it's trustworthy. – das Keks Nov 03 '19 at 18:34
  • Also see https://community.jaspersoft.com/questions/1071031/itext-js6-dependency-issue – Reto Höhener Apr 28 '20 at 10:35
  • Adding the JFrog repository (`http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/`) to my `build.gradle` solved the problem! Thanks – dk7 Sep 05 '20 at 21:33
  • Thank you so much. Saved my day :) +1 – Anish B. Dec 22 '20 at 11:24
6

We decide to maintain same jasperreport version and made this changes in conflicteds pom:

<dependencies>
    <dependency>
            <groupId>jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>2.0.1</version>
            <exclusions>
                <exclusion>
                    <groupId>com.lowagie</groupId>
                    <artifactId>itext</artifactId>
                </exclusion>
            </exclusions>           
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>
...
</dependencies>

Edit: Change dependecy to 2.1.7 to be certain it will compile in future

Laura Abad Avilés
  • 498
  • 1
  • 5
  • 13
6

JasperReports patched the iText with some bug fixes. So you have to add the patched iText repo[1] in your pom/gradle file.

[1] http://jasperreports.sourceforge.net/maven2/

Below is the gradle snippet for your reference when using jasper report 6.1.1. repositories { mavenLocal() mavenCentral() maven { url "http://repo.spring.io/release" } maven { url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/" } maven { url "http://jasperreports.sourceforge.net/maven2/" } }

Joris Schellekens
  • 7,482
  • 1
  • 18
  • 47
Kane
  • 7,392
  • 4
  • 41
  • 66
4

Answer for searchers in 2k19

Artifact:

<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>

is deprecated now.

Better to exclude it from jasperreports and add new itext dependency manually

<dependency>
    <groupId>jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.10.0</version> <!--(or higher)-->
    <exclusions>
        <exclusion>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.5.13</version> <!--(or higher)-->
</dependency>
xardbaiz
  • 353
  • 2
  • 12
3

I was making manteinance to some legacy code, and i faced the same problem. The solution that i found was to add the following to the pom.xml:

<repositories>
  <repository>
    <id>jasper-3rd-party</id>
    <name>Jasper3rdParty</name>
    <url>http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
  </repository>
</repositories>

<dependencies>

  <dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.12.2</version>
  </dependency>

  <!-- More dependencies like: commons-collections4, org.apache.xmlgraphics, etc -->

  <dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>2.1.7.js4</version>
  </dependency>

</dependencies>

The JasperReports version used to test this code was released on Mar/2020. Hope this helps!

Nelson
  • 93
  • 1
  • 1
  • 5
  • 1
    Why do they keep depending on custom versions of itext but not publishing them? This is so painful... – rogerdpack Apr 23 '21 at 13:47
  • @rogerdpack Itext changed its license to AGPL in later versions, which is why JasperReports uses the old version with some bugfixes. They are not allowed to publish those to central. – BluE Apr 26 '21 at 05:49
  • I'd assume they could change the coordinates and publish their own full version, since the 2.x versions are MIT license or something...? – rogerdpack Apr 26 '21 at 16:07
1

We have the same problem. To solve it, we have deleted the proxy parameters of the Maven config, and change the last version of the maven-metadata-central (in folder com\lowagie\itext of your repository).

A bad solution, but, temporaly, works :/

Usul Yo
  • 11
  • 3
  • Your temporal solution (don't works with Jenkins) brights me the idea. That [link](http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html) talks about version ranges (that jasperreports in my question uses) and how maven gets the newest version if you do it. That problem from jasperrreport pom.xml added with Itext update, what tells maven that version 4.2.2 is latets but haven't .jar causes the problem. Good solution is maven central update the metadata, not we. – Laura Abad Avilés Jul 09 '15 at 12:22
  • I only see the "contact us" in the web of mvnrepository... Other options is exclude the worng version. Suerte. – Usul Yo Jul 09 '15 at 12:33
  • I create an issue in maven. Only that I can do now is wait that someone with permission update the metadata or work without connection. [Mavens jira](https://issues.apache.org/jira/browse/MNGSITE-250) – Laura Abad Avilés Jul 09 '15 at 12:40
  • With the exclusions you can take the version that you want (i think): jasperreports jasperreports 3.0.0 com.lowagie itext – Usul Yo Jul 09 '15 at 13:28
  • And taking de 4.2.1 vesion com.lowagie itext 4.2.1 compile But someone has changed something of the version 2.4.x today http://repo1.maven.org/maven2/com/lowagie/itext/ – Usul Yo Jul 09 '15 at 13:29
  • @LauraAbadAvilés I was just in touch with the person responsible for the change (the person with the ownership of the project). He asked me if it was OK for him to make the jars for iText 4.2.0 and 4.2.1 empty too. I asked him to wait as that would break even more builds. I suggest that you follow the advice given in the above comment. – Bruno Lowagie Jul 09 '15 at 13:35
  • @BrunoLowagie I'm Ok with owner proposal, if com.lowagie owner only release to 2.1.7 it's correct to say that it is the latest version of it and mail the other company that load that jar (4.2.0 & 4.2.1) to delete and move to other groupId. It solves the problem and the other company can update it's jar to his version and load in maven.central correctly. I think this solution will solve the problem, don't you? – Laura Abad Avilés Jul 10 '15 at 07:13
  • 1
    The problem is, that other company probably does not exist any more. – Amedee Van Gasse Jul 10 '15 at 08:46
0

I have the same problem when using Maven 2.2.1, i re-built my project using Maven 3.2.3 and its works !

You have to use Maven 3 to resolve your problem, the bug seem to be resolved in this version.

Meher
  • 123
  • 2
  • 13
  • 1
    Could you please tell me which version of itext is actually used? – Amedee Van Gasse Jul 09 '15 at 17:06
  • i'm not using itext directly, but JasperReports 1.3.2 references itext 4.2.2 – Meher Jul 10 '15 at 12:09
  • JasperReports `1.3.2` (April 2007) references `iText [1.02b,)`, that means any version at or above `1.02b`, until infinity and beyond. If you look at http://mvnrepository.com/artifact/jasperreports/jasperreports/1.3.2, you will see that the iText dependency has version `5.5.6` in the column Updates. That would be `com.itextpdf:itextpdf:jar:5.5.6`. – Amedee Van Gasse Jul 10 '15 at 12:18
0

"Fix" for me was to switch from jasperreports version 5.5.0 to 4.5.1 LOL. (which doesn't depend on itext)

Then it doesn't depend on a custom, seemingly unpublished dependency version of itext (2.1.7.js2 in my case).

You could download 2.1.7.js2.jar and publish it locally to your "own" custom maven repo, or ~/.m2/repository (ugh). I've even seen people have a custom ivy command to "publish" a local copy of it to a local server.

Or add the repo's in the other answers. Or just specify it manually as 2.1.7, which is in the repo's, etc. (you'll miss some bug fixes though).

rogerdpack
  • 50,731
  • 31
  • 212
  • 332