Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven can't find dependencies [dependencyResolutionException]

I added a Maven dependency to my project and my project compiles locally, while it doesn't compile on server. It can not resolve the newly added dependency.

This is my pom.xml file:

    <repositories>
        <repository>
            <id>rep</id>
            <name>Repository</name>
            <url>http://artifacts.com/rep</url>
            <releases>
               <enabled>true</enabled>
               <updatePolicy>always</updatePolicy>
            </releases>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.project.rest</groupId>
            <artifactId>common</artifactId>
            <version>2.0.5</version>
        </dependency>
    </dependencies>

And this my console output with an error:

 Downloading: http://artifacts.com/rep/com/project/rest/common/2.0.5/common-2.0.5.pom
    [WARNING] The POM for com.project.rest:common:jar:2.0.5 is missing, no dependency information available

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 6.154s
    [INFO] Finished at: Tue Feb 03 06:58:35 BRT 2015
    [INFO] Final Memory: 9M/152M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project server: Could not resolve dependencies for project org.server:
    server:jar:2.5.1-SNAPSHOT: The following artifacts could not be resolved: com.project.rest:common:jar:2.0.5:
    Could not find artifact com.project.rest:common:jar:2.0.5 in rep (http://artifacts.com/rep) -> [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

(I hid all real URLs and package.)

What could be the problem?

like image 767
lapots Avatar asked Feb 03 '15 10:02

lapots


3 Answers

The first line "Downloading:..." only says that maven tries to download the artifact. It is no statement about success. If maven is successful you will get another line starting with "Downloaded: ..."

So in your case maven was not able to download the file. Check the logged url in your browser if it does exist and if it is protected.

BTW <updatePolicy>always</updatePolicy> is quite uncommon for release repos, because releases should not change any more.

like image 160
Horst Krause Avatar answered Sep 19 '22 02:09

Horst Krause


DependencyResolutionException

(source: Maven Confluence)

This error generally occurs when Maven could not download dependencies. Possible causes for this error are:

  1. The POM misses the declaration of the <repository> which hosts the artifact.
  2. The repository you have configured requires authentication and Maven failed to provide the correct credentials to the server. In this case, make sure your ${user.home}/.m2/settings.xml contains a <server> declaration whose <id> matches the <id> of the remote repository to use. See the Maven Settings Reference for more details.
  3. The remote repository in question uses SSL and the JVM running Maven does not trust the certificate of the server.
  4. There is a general network problem that prevents Maven from accessing any remote repository, e.g. a missing proxy configuration.
  5. You have configured Maven to perform strict checksum validation and the files to download got corrupted.
  6. Maven failed to save the files to your local repository, see LocalRepositoryNotAccessibleException for more details.
  7. In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -U to the command line.

In case of a general network-related problem, you could also consult the following articles:

  • Configuring a Proxy
  • Security and Deployment Settings
  • Guide to Remote Repository Access through Authenticated HTTPS
like image 24
naXa Avatar answered Sep 20 '22 02:09

naXa


Make sure your repository is configured properly. Try to search, in your repo, for com.project.rest:common of version 2.0.5.

Is this your own project? some jar that you have built? are you sure you deployed it to your repo? if it is not in your repo, try to search for it in your local repo (usually .m2/repository/com/project...)

like image 26
OhadR Avatar answered Sep 19 '22 02:09

OhadR