Dean Schulze
Dean Schulze

Reputation: 10303

Maven can't resolve the dependency it just found

Maven must be losing its mind.

I added a dependency using Netbeans Add Dependency dialog. I searched for jax-rs-ri. It updated the index from central and showed several versions of jax-rs-ri. I selected 1.9.1 and it added this to the pom.xml:

    <dependency>
        <groupId>com.sun.jersey.ri</groupId>
        <artifactId>jax-rs-ri</artifactId>
        <version>1.9.1</version>
    </dependency>

Looks right, but when I build I get the following error:

Failed to execute goal on project reply-to.test-web: 
Could not resolve dependencies for project jms:reply-to.test-web:war:1.0-SNAPSHOT: 
Could not find artifact com.sun.jersey.ri:jax-rs-ri:jar:1.10-b03 in 
central (http://repo1.maven.org/maven2) -> [Help 1]

I've also tried changing the repository the following with the same results:

 <repositories>
    <repository>
        <id>maven2-repository.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>http://download.java.net/maven/2</url>
        <layout>default</layout>
    </repository>
</repositories>

This was working earlier today. Did something just get broken with Maven?

Upvotes: 2

Views: 4513

Answers (1)

palacsint
palacsint

Reputation: 28885

In these cases it's worth to check the local repository (usually c:\Users\<username>\.m2\repository\com\sun\jersey\ri\jax-rs-ri or /home/<username>/.m2/repository/com/sun/jersey/jax-rs-ri) and Central: http://search.maven.org/#artifactdetails|com.sun.jersey.ri|jax-rs-ri|1.9.1|pom (The important part now is the "Available Downloads" table.)

So, there isn't any jar file just a zip (and the POM). You should use <type>zip</type> in your dependency like this:

<dependency>
    <groupId>com.sun.jersey.ri</groupId>
    <artifactId>jax-rs-ri</artifactId>
    <version>1.9.1</version>
    <type>zip</type>
</dependency>

Since it's a zip maybe you want to unpack it. This answer could help: Unzip dependency in maven

Please note that 1.9.1 is not the latest jax-rs-ri version and your Maven uses 1.10-b03. If you want to force it to use 1.9.1 you have to use <version>[1.9.1]</version> inside the dependency tag.

Upvotes: 6

Related Questions