2

I'm currently having trouble trying to add add the dependency of another Maven project (specifically Aerospike) into my project. I already did a mvn install on the Aerospike project so in my repository (on Linux: ~/.m2/repository/com/aerospike/aerospike-client/3.0.6) I see a aerospike-client-3.0.6.jar.lastUpdated file. However, when I add the dependency

<dependency>
    <groupId>com.aerospike</groupId>
    <artifactId>aerospike-client</artifactId>
    <version>3.0.6</version>
    <scope>compile</scope>
</dependency>

into my project and perform an mvn install, it returns this error:

[INFO] ------------------------------------------------------------------------
[INFO] Building in-memory database poc 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.aerospike:aerospike-client:jar:3.0.6 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.601s
[INFO] Finished at: Fri Aug 16 11:49:43 EDT 2013
[INFO] Final Memory: 18M/954M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project: Could not resolve dependencies for project: Failure to find com.aerospike:aerospike-client:jar:3.0.6 in http://repository.jboss.org/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group 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

Thanks in advance!

Didier Spezia
  • 70,911
  • 12
  • 189
  • 154
ksdnlee
  • 91
  • 2
  • 10
  • 1
    Can you list/tree what you have in ~/.m2/repository/com/aerospike/aerospike-client/3.0.6 please. (on windows it's: C:\Users\<$USER>\.m2\...) – fabien Aug 16 '13 at 17:36
  • 1
    I have updated the question with the detailed repository location. thanks – ksdnlee Aug 16 '13 at 17:43
  • "resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced" - have you tried forcing the updates? just add a -U when running from command line. – linski Aug 16 '13 at 18:22
  • linski, thank you for your suggestion. i tried it and i got the same error. – ksdnlee Aug 16 '13 at 18:44
  • In a situation like this I usually manually delete the problematic version from the repo. But, I don't see any com/aerospike/aerospike-client folder in that repo https://repository.jboss.org/nexus/content/groups/public/. How did you get that dependency? – linski Aug 16 '13 at 19:01
  • The binary is not found in the repository. I have the Maven project on my local machine and I build aerospike project with an "mvn install" which created the aerospike-client module. How can I configure my pom.xml to add the aerospike-library into my own project at this point? Thanks! – ksdnlee Aug 16 '13 at 19:08
  • @ksdnlee any update on the matter? – linski Aug 21 '13 at 16:57
  • @linski I have up'd your answer, it really helped a lot! Thank you so much! – ksdnlee Sep 11 '13 at 22:13
  • @ksdnlee np, glad to help. have you managed to solve the problem? – linski Sep 12 '13 at 08:17

1 Answers1

1

Problem

The console output says that Maven is searching for com.aerospike:aerospike artifact in the JBoss public repository but that artifact isn't there.

Failure to find com.aerospike:aerospike-client:jar:3.0.6 in                                         
http://repository.jboss.org/nexus/content/groups/public

The OP stated that he installed it locally.

Discussion

Maven is trying to download a locally installed artifact from a remote repository that does not have that artifact. By default dependencies are first searched in local repository. AFAIK, the only thing that can override this behavior are the artifact update policies defined in settings.xml.

AFAIK, the offline build (-o) should override any such policies. I tried to reproduce this situation by deleting dependencies from my local repo and intentionally declaring nonexistent dependencies and Maven acted as documented (offline build does not try to download). I have not played with update policies though.

Solution

Following up on the comments, I have verified the offline build procedure in the following environment:

Apache Maven 3.1.0 
Java version: 1.7.0_25, vendor: Oracle Corporation
OS name: "linux", version: "3.2.0-23-generic", arch: "amd64", family: "unix"

The offline build procedure in short:

  • download all the online dependencies
  • install all the offline dependencies
  • run offline build

All the commands are run from the project root folder.

First, comment all the dependencies that are not found in any remote repository from your pom, e.g.:

<!--
 <dependency>
        <groupId>does</groupId>
        <artifactId>not</artifactId>
        <version>exist</version>
 </dependency>
-->

Prepare the offline build by downloading all the dependencies:

mvn dependency:go-offline

If you don't comment out the missing dependencies this goal will fail. You can verify it by observing that Maven has successfully downloaded all the artifacts in your console output.

Next, install the missing dependencies manually in your local repo:

mvn install:install-file -Dfile=<PATH_TO_MISSING_DEP_JAR_FILE> 
                         -DgroupId=does  
                         -DartifactId=not   
                         -Dversion=exist 
                         -Dpackaging=jar 

That will produce not-exist.jar (a copy of <PATH_TO_MISSING_DEP_JAR_FILE>) and not-exist.pom along with metadata files in your local repository under <LOCAL_REPO_PATH>/.m2/repository/does/not/exist/

Verify that those files exist under that exact directory structure. Default locations of your local repository for different platforms are here, but if it isn't there, then run:

mvn help:effective-settings > settings.log

which will dump the interpolated settings for your project to settings.log file. Open it with a text editor and read the path of your local repo under:

<settings>
  ...
  <localRepository>/path/to/local/repo/</localRepository>
  ...
</settings>

Now you can run your build in offline mode:

mvn clean install -o

You can set offline mode in your settings file also, but that will set offline mode for a specified user or system-wide as opposed to command line switch which is per project when you want it.

Conclusion

Carefully run this procedure exactly as described, and if you still can't build your project, then please run:

mvn help:effective-pom > pom.log
mvn help:effective-settings > settings.log

and post the contents of pom.log and settings.log files here.

Community
  • 1
  • 1
linski
  • 5,046
  • 3
  • 22
  • 35
  • interesting. 1) have you tried the -o switch? 2) what does mvn -version output? – linski Aug 16 '13 at 20:00
  • I have tried the -o and -U switch and I get the same error. The mvn -version output is `Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 22:15:3 2-0400) Maven home: /opt/apache-maven-3.1.0 Java version: 1.7.0_25, vendor: Oracle Corporation Java home: /usr/java/jdk1.7.0_25/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.39-400.17.1.el6uek.x86_64", arch: "amd64", family: "unix"` I tried commenting out the repository and it just started searching from another repository. Is there a way to force Maven to search in its local repository? – ksdnlee Aug 16 '13 at 20:02
  • yes, by using -o switch. I just verified that, I deleted a dep from my project and ran it with -o switch, and the build failed. Without it suceeded. I have Maven 3.0.4. There is another way maybe, just a sec – linski Aug 16 '13 at 20:12
  • 1
    It seems that even with the -o switch it is still searching for the .jar file in the jboss repository. Thank you linski so much for your help! – ksdnlee Aug 16 '13 at 20:14
  • Uh I'm done for today, my version is older than yours :)). I'll try it tommorrow morning if no one answers it, good luck until then. – linski Aug 16 '13 at 20:28