Error in the project after adding IReport dependency

3

When I add the following dependency the project and pom.xml get error:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>5.1.2</version>
    <scope>compile</scope>
</dependency>

Error:

  

Description Resource Path Location Type ArtifactDescriptorException:   Failed to read artifact descriptor for   net.sf.jasperreports: jasperreports: jar: 5.1.2:   ArtifactResolutionException: Failure to transfer   net.sf.jasperreports: jasperreports: pom: 5.1.2 from    link was cached in the local repository,   resolution will not be reattempted until the update interval of   prime-repo has elapsed or updates are forced. Original error: Could   not transfer artifact net.sf.jasperreports: jasperreports: pom: 5.1.2   from / to prime-repo ( link ): connect timed   out pom.xml / SystemSuspensao line 1 Maven Dependency Problem

And it's not just that, all other dependencies get wrong too:

I've tried several versions of the library and the error persists.

    
asked by anonymous 06.08.2015 / 19:17

2 answers

2

The file does not exist in the repository. At least I did not find it. So the error.

It may be that the repository is wrong, or some problem in the repository itself.

One solution would be to add the .jar manually to the .m2 folder (if using Linux) and to the application container, in addition to changing the <scope> to provided .

Or if the problem is in the repository, wait for it to correct it and then try again.

    
06.08.2015 / 21:15
1

The error is due to maven not having been able to resolve the dependency on any of the repositories that are configured, either from the repositories that are standard, or from what you've specified in your settings (in the case of Primefaces ).

Instead of manually adding the dependency to your local repository (by default found in .m2 in the user directory) you can add a repository that has such a dependency, since there is an online and public repository that has it.

The sonatype repository (heavily used, inclusive) has the dependency you need. So to resolve dependency on it, just add something like this to your pom.xml :

<repository>
    <id>sonatype-releases</id>
    <url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>

And after that you will be able to solve it, in the way you have declared or removed the compile scope that is standard, and it can look like this:

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

The approach of saying that dependencies that by nature do not come up with scope provided should be avoided ( see the meaning of each scope ), since there is a great chance of errors occurring.

Below is a complete example of pom.xml using the configuration as stated:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.brunocesar</groupId>
    <artifactId>jasper-dependency</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>5.1.2</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>sonatype-releases</id>
            <url>https://oss.sonatype.org/content/repositories/releases/</url>
        </repository>
    </repositories>

</project>

This is the dependency download log:

[INFO] ------------------------------------------------------------------------
[INFO] Building jasper-dependency 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.pom
Downloaded: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.pom (13 KB at 7.5 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.jar
Downloaded: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.jar (4428 KB at 402.8 KB/sec)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jasper-dependency ---
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jasper-dependency ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.988 s
[INFO] Finished at: 2015-08-07T10:51:48-03:00
[INFO] Final Memory: 10M/183M
[INFO] ------------------------------------------------------------------------

As you can see the download was done from the quoted and configured repository. As in your case went wrong, some possible causes are:

  • wrong configured repository;
  • cache in the local maven repository, force update using mvn clean compile -U or some other lifecycle
07.08.2015 / 01:08