Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus: Could not find artifact

Recently I've migrated from Archiva to Sonatype Nexus.

I'm trying to use Jars from 3rd party repositories and Nexus does not cache it into the local repository.

I've searched for answers in this section and couldn't one that answers the question.

Here is what I did...

I'm using settings.xml :

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://THE_URL:8080/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>admin</id>
      <username>user</username>
      <password>password</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>

        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>

      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

I've also created proxy repositories for all the 3rd party repositories I'm using, and ADDED THEM TO THE NEXUS PUBLIC GROUP.

Next, I've run the command:

mvn clean install

and got the following error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building shlang 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://THE_URL:8080/nexus/content/groups/public/com/shadow/shadow/1/shadow-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.341s
[INFO] Finished at: Sun Jun 30 11:59:42 IDT 2013
[INFO] Final Memory: 6M/120M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project shlang: Could not resolve dependencies for project com.shadow:shlang:jar:1.0-SNAPSHOT: Failed to collect dependencies for [couchbase:couchbase-client:jar:1.1.5 (compile), com.google.code.gson:gson:pom:2.2.2 (compile), org.json:json:jar:20090211 (compile), net.sf.json-lib:json-lib:jar:jdk15:2.4 (compile), jline:jline:jar:2.10 (compile), commons-validator:commons-validator:jar:1.4.0 (compile), spy:spymemcached:jar:2.8.1 (compile), com.shadow:util:jar:1.0.1 (compile), com.shadow:monkey_schoolyard:jar:1.0.0 (compile)]: Failed to read artifact descriptor for com.shadow:util:jar:1.0.1: Could not find artifact com.shadow:shadow:pom:1 in nexus (http://THE_URL:8080/nexus/content/groups/public) -> [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 result in the local repo is that it does not contained any of the 3rd party jars it should.

What do I miss here?

like image 337
raven99 Avatar asked Jun 30 '13 09:06

raven99


People also ask

Can't find artifact Jenkins nexus?

If you are unable to find an artifact that you just know is there locally in your Nexus, the most likely causes of failure are: The proxy repository containing the artifact is not in your group repository. The download was blocked by a routing rule.

Where are artifacts stored in Nexus?

Hosted Repositories A Hosted Repository contains artifacts which have been published to a Nexus instance. These published artifacts are stored in the Sonatype Work directory. This can include repositories that hold release artifacts and repositories that hold snapshot artifacts.

How do I delete old artifacts from Nexus?

First you have to define a cleanup policy. Then you have to attach the cleanup policy to one or more repositories. The “Cleanup repositories using their associated policies” task will then execute the cleanup policies. The documentation about Cleanup Policies can be found here.


3 Answers

Most likely your local Maven repository has the fact that the component can not be found cached. You can force Maven to check for updates of snapshot versions and existence of previously not found version with the -U flag.

So run

mvn clean install -U

Sometimes if thing are really weird it can help to completely delete the respective folder structure in your local repository. So in your example

rm -rf ~/.m2/repository/com/shadow/
like image 127
Manfred Moser Avatar answered Oct 31 '22 08:10

Manfred Moser


If Manfred's solution does not work for you, then the issue will be with Nexus trying to resolve the artifact.

If you use a browser you can check what Nexus is actually doing to locate the artifact you are after.

Append ?describe to the url of the Nexus repository with the path of the artifact.

E.g. Nexus Repository Public Repositories URL: http://my.nexus.server.address:8081/nexus/content/groups/public/

Fetching the artifact

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>

Path of the above artifact would be: org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar

So the full URL to check

http://my.nexus.server.address:8081/nexus/content/groups/public/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar?describe

This process will then proceed through the list of repositories configured under your Public Repositories group in the order that the repositories are specified, indicating why a repository was unable to provide the requested artifact.

Most reasons are pretty self-explanatory and can be ignored.

One reason that may be of interest is when the error is still cached as not found for repository is retrieved for a repository.

This indicates that at some point Nexus has tried to retrieve the artifact and failed to locate it.

This status seems to be cached within Nexus, so the quickest way to clean out the cache is to restart Nexus.

like image 8
sweetfa Avatar answered Oct 31 '22 09:10

sweetfa


If all else fails, make sure that your pom and XML tags are clean of invisible characters (strip special chars, copy from a standard source like mvnrepository.com, retype manually, whatever).

I had a tricky invisible character corrupting my nexus lookup (only from the maven build) and spent an embarrassing amount of time debugging it since everything else I tried worked fine.


Here was my example (revealed by http://www.nousphere.net/cleanspecial.php):

<dependency>
    <groupId>uk.co.jemos.podam</groupId>
    <artifactId>podam</artifactId>
    <version>&#8206;7.2.1.RELEASE</version>
    <scope>test</scope>
</dependency>

See that junk hiding in front of the version?

like image 1
Marquee Avatar answered Oct 31 '22 09:10

Marquee