Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved dependencies error when following Jersey 2.0 user guide

Update: This does not/should not occur anymore, see accepted answer. If you are facing this problem with some other jar, it is typically a transient thing. You can try some of the workaround suggested in other answers.

I am following the instructions from Jersey 2.0 user guide. When I reach 1.3 (running the project, I get the following failure:

[ERROR] Failed to execute goal on project xxx-service: Could not resolve dependencies for project xxx.restapi:xxx-service:jar:1.0-SNAPSHOT: Failure to find javax.annotation:javax.annotation-api:jar:1.2 in https://maven.java.net/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of snapshot-repository.java.net has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

The problem seems to be that there is no https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar

If we go up to https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/ we see that the folders and jar files inside those folders are renamed with a suffix of -b01 etc.

The pom itself does not have any direct reference to this annotations jar. So I guess the question is: How do I adjust that dependency? What do I put in the POM file that will get that dependency resolved correctly?

like image 307
Kinjal Dixit Avatar asked May 30 '13 06:05

Kinjal Dixit


3 Answers

In the meanwhile, this problem no longer occurs. javax.annotation:javax.annotation-api:jar:1.2 is now available on Maven central.

like image 79
oberlies Avatar answered Oct 24 '22 01:10

oberlies


I had to add the following the pom.xml to resolve this problem:

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.2-b04</version>
</dependency>

depending on when you are viewing this, you should go to https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/ and check what is the latest version.

like image 39
Kinjal Dixit Avatar answered Oct 24 '22 03:10

Kinjal Dixit


javax.annotation-api.jar version 1.2 is published on the java.net maven repository @ https://maven.java.net

follow this link to search for version 1.2 :

https://maven.java.net/index.html#nexus-search;gav~javax.annotation~javax.annotation-api~1.2~~

you can instruct maven to fetch artifacts from java.net maven repository by adding it to the section of your pom.xml. e.g.

<repositories>
    <repository>
        <id>java.net.repo</id>
        <url>https://maven.java.net/content/groups/promoted/</url>
        <layout>default</layout>
    </repository>
</repositories>
like image 1
cthiebaud Avatar answered Oct 24 '22 01:10

cthiebaud