0

Since today we can't build our jasper file any more. We use the jasperreports-maven-plugin for this.

In maven 2.2.1, this was configured like this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jasperreports-maven-plugin</artifactId>
    <version>1.0-beta-2</version>
    <executions>
      <execution>
        <goals>
          <goal>compile-reports</goal>
        </goals>
        <configuration>
          <sourceDirectory>${basedir}/src/main/resources/reports</sourceDirectory>
          <outputDirectory>>${project.build.directory}/classes/reports</outputDirectory>
        </configuration>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>5.5.1</version>
        <scope>compile</scope>
      </dependency>
      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>compile</scope>
      </dependency>
    </dependencies>
    <configuration>
      <sourceDirectory>C:\Windows\TEMP/src/main/resources/reports</sourceDirectory>
      <outputDirectory>C:\Windows\TEMP\target/classes/reports</outputDirectory>
    </configuration>
  </plugin>

But, as said, since today, we got this build error:

...
Downloading: http://repo1.maven.org/maven2/itext/itext/4.2.0/itext-4.2.0.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) itext:itext:jar:4.2.0

  Try downloading the file manually from the project website.

  Then, install it using the command:
  mvn install:install-file -DgroupId=itext -DartifactId=itext -Dversion=4.2.0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there:
  mvn deploy:deploy-file -DgroupId=itext -DartifactId=itext -Dversion=4.2.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
    1) org.codehaus.mojo:jasperreports-maven-plugin:maven-plugin:1.0-beta-2
    2) jasperreports:jasperreports:jar:1.2.0
    3) itext:itext:jar:4.2.0

I think another question (Dependency error in jasper-reports from itext) is related to his. And I tried the solution of Meher to use maven 3.2.3. This seems to be a solution, but we can't upgrade (now) to this maven version. So I need another solution to resolve this issue. Any ideas? I already tried to exclude dependencies and use fixed versions, but I haven't managed to succeed my build. What I mean is this:

<!-- Compile jasper reports -->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jasperreports-maven-plugin</artifactId>
    <version>1.0-beta-2</version>
    <configuration>
        <sourceDirectory>${basedir}/src/main/resources/reports</sourceDirectory>
        <outputDirectory>${project.build.directory}/classes/reports</outputDirectory>
    </configuration>

    <executions>
        <execution>
            <goals>
                <goal>compile-reports</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>

    <dependencies>
        <dependency> 
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jasperreports-maven-plugin</artifactId>
            <version>1.0-beta-2</version>
            <exclusions>
                <exclusion>
                    <groupId>net.sf.jasperreports</groupId>
                    <artifactId>jasperreports</artifactId>                              
                </exclusion>                            
            </exclusions>
        </dependency> 

        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>5.5.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>
</plugin>

Why is the plugin still searching for itext:itext:jar:4.2.0? Any ideas or suggestions to solve this?

Thanks!

Community
  • 1
  • 1
Joris
  • 133
  • 1
  • 8
  • I think it should be enough to replace the central repository url. It may just be using https - so the current url is still: https://repo.maven.apache.org/maven2/ - so in you settings.xml add a repository with id "central" and let it point to that url. itext is still there. – wemu Jul 13 '15 at 20:00
  • So, you mean I can find itext 4.2.0 in this repository? I already tried this, and it isn't there. That's why I am trying to use a fixed version of itext. – Joris Jul 13 '15 at 20:12
  • hm. I think the groupId is not correct. itext:itext is for ealrier versions. the 4.2.x versions have com.lowagie:itext (groupId:artifactId). I would use "mvn help:dependency-tree" to figure out where that dependency comes from. Maybe the transitive dependency is ok but it is overwritten by something in your own pom.xml – wemu Jul 14 '15 at 07:13
  • The depency tree is jasperreports-maven-plugin / jasperreports / itext. So, the cause is somewhere in the plugin depencies – Joris Jul 14 '15 at 08:03
  • According to the jasperreports `6.1.0` pom.xml on Maven Central, they depend on `com.lowagie:itext` `2.1.7.js`. That's a version of iText especially for jasperreports. Which version of jasperreports are you using? – Amedee Van Gasse Jul 14 '15 at 12:29

3 Answers3

3

Background:

iText Group NV is owner of the groupId com.lowagie and com.itextpdf on Maven Central. iText Group NV released com.lowagie:itext version 2.1.7 in July 2009. The next release by iText Group NV was com.itextpdf:itextpdf version 5.0.0, in December 2009. The current version (as of December 2015) is 5.5.8.

iText Group NV never released a version 4.x.x.

Somewhere in 2011, a company called InProTopia "hijacked" com.lowagie and released a fork of iText with version number 4.2.0. According to the [Guidelines of Maven Central][1], they should have published this as com.inprotopia:itext, but they didn't. Later they published a 4.2.1 with their own patches. Recently iText Group NV took ownership of com.lowagie and published a version 4.2.2 with redirection to com.itextpdf:itextpdf version 5.5.6 (the current version at that time).

Possible solutions:

  1. If you need com.lowagie iText, you need to set a fixed version in your pom.xml. The last official release is 2.1.7.
  2. If you need iText 4.x.x, contact InProTopia. Good luck with that, because their website is down, and as far as I could find out, that company no longer exists.
  3. If you don’t mind which version of iText you use, use the current version of iText published by iText Group NV, com.itextpdf:itextpdf 5.5.8 (as of December 2015).
  4. Use the latest version of jasperreports. It has an explicit dependency on iText 2.1.7.js, which a custom iText version for Jasper Reports.

More info at the iText blog. http://itextpdf.com/maven-update-problem-with-itext-4.2.2

[1] https://maven.apache.org/guides/mini/guide-central-repository-upload.html

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
  • I indeed want to use itext 2.1.7, but I have difficulties in using this version (instead of 4.2.0). In our project we use jasperreports 5.5.1 and itext 2.1.7, but the jasperreports-maven-plugin still wants to use 4.2.0 for some reason. – Joris Jul 14 '15 at 08:52
  • In that case I suggest you contact Jasper Reports for support. – Amedee Van Gasse Jul 14 '15 at 08:54
0

I resolved my issue by using ant to build my jasper report. So I skipped the plugin.

My ant task looks like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>${maven-antrun-plugin.version}</version>
    <executions>
        <execution>
            <id>compile-jasper-reports</id>
            <goals>
                <goal>run</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>         
                <target>
                        <echo message="Start compile of jasper reports"/>                               
                            <mkdir dir="${project.build.directory}/classes/reports"/>

                    <taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask" classpathref="maven.compile.classpath" />
                    <jrc srcdir="${basedir}/src/main/resources/reports"
                         destdir="${project.build.directory}/classes/reports"
                         tempdir="${project.build.directory}/classes/reports"
                         keepjava="true"
                         xmlvalidation="true">
                           <classpath refid="maven.compile.classpath"/>
                           <include name="**/*.jrxml"/>
                    </jrc>                              
                    </target>
            </configuration>
        </execution>
    </executions>
</plugin>
Joris
  • 133
  • 1
  • 8
  • This works, because I don't see you setting a version for jasperreports, so you are using the latest version, which has a dependency on itext `2.1.7.js`, see answer above. (solution 4) – Amedee Van Gasse Jul 14 '15 at 12:42
0

Try add this repository:

<repository>
        <url>https://repository.liferay.com/nexus/content/groups/public/</url>
        <id>liferay</id>
        <name>Liferay</name>
    </repository>

Good luck!