Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven project cannot locate dependencies in local repository

Tags:

java

maven-2

I have a maven project setup.

In my maven POM file, it is defined as below:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.myProject</groupId>
        <artifactId>basePOM</artifactId>
        <version>1.0</version>
        <relativePath>../../../shared/common/pom.xml</relativePath>
    </parent>

    <groupId>com.myProject.services</groupId>
    <artifactId>orderservice</artifactId>
    <version>developer</version>
    <packaging>war</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!--Internal dependencies-->
        <dependency>
            <groupId>com.myProject.shared</groupId>
            <artifactId>model</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-spring</artifactId>
        </dependency>
    </dependencies>
</project>

I have a parent POM which defines some common bits:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <name>Base POM</name>
    <groupId>com.myProject</groupId>
    <artifactId>basePOM</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.myProject.shared</groupId>
                <artifactId>model</artifactId>
                <version>developer</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-jaxrs</artifactId>
                <version>1.2.GA</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-simple</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-spring</artifactId>
                <version>1.2.GA</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

When I run

mvn clean install

The resteasy-jaxrs and resteasy-spring are downloaded to my local repository without problem.

However, it then produces an error said:

**[ERROR] Failed to execute goal on project orderservice: Could not resolve dependencies for
 project com.mxyy.services:orderservice:war:developer: Failed to collect dependencies for
[com.mxyy.shared:model:jar:developer (compile), org.jboss.resteasy:resteasy-jaxrs:jar:1.2.
GA (compile), org.jboss.resteasy:resteasy-spring:jar:1.2.GA (compile), org.testng:testng:j
ar:jdk15:5.8 (test)]: Failed to read artifact descriptor for com.mxyy.shared:model:jar:dev
eloper: Failure to find com.mxyy:basePOM:pom:1.0 in http://repo.maven.apache.org/maven2 wa
s cached in the local repository, resolution will not be reattempted until the update inte
rval of central has elapsed or updates are forced -> [Help 1]**

It looks like the project cannot pickup the dependencies already in my local repository.

Can someone let me know how I can solve this problem?

Many thanks

More Info:

I have temporarily removed the dependency com.myProject.shared. Now the error message becomes:

[ERROR] Failed to execute goal on project orderservice: Could not resolve dependencies for project com.mxyy.services:orderservice:war:developer: Faile
d to collect dependencies for [org.jboss.resteasy:resteasy-jaxrs:jar:1.2.GA (compile), org.jboss.resteasy:resteasy-spring:jar:1.2.GA (compile)]: Faile
d to read artifact descriptor for org.scannotation:scannotation:jar:1.0.2: Could not transfer artifact org.scannotation:scannotation:pom:1.0.2 from/to
 jboss (http://repository.jboss.org/maven2): Access denied to: http://repository.jboss.org/maven2/org/scannotation/scannotation/1.0.2/scannotation-1.0
.2.pom, ReasonPhrase:Forbidden. -> [Help 1]
like image 538
Kevin Avatar asked Feb 19 '12 09:02

Kevin


People also ask

How do I force Maven to download dependencies?

We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository. Here, -U,--update-snapshots : Forces a check for missing releases and updated snapshots on remote repositories.


2 Answers

Well, looks like the access is forbidden.

You need to use the right path to JBoss repository: https://repository.jboss.org/nexus/content/groups/public-jboss/

Here is the artifact you need: https://repository.jboss.org/nexus/content/groups/public-jboss/org/scannotation/scannotation/

So, mention in your POM:

    <repository>
        <id>JBoss</id>
        <name>JBoss</name>
        <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
    </repository> 

in repositories list

like image 105
weekens Avatar answered Oct 05 '22 15:10

weekens


mvn clean install your model project first. That will install its artifacts into your local repo where your target build can find them.

Edit:

If this still does not help, use the -X switch to display more error/debug information:

mvn -X clean install
like image 39
Bohemian Avatar answered Oct 05 '22 15:10

Bohemian