Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-resolvable parent POM using Maven 3.0.3 and relativePath notation

After migrating to Mavent 3.0.3 Parent poms in several Projects cannot be resolved anymore.

The Projects are structured in a default manner, so I set parent.relativePath to "../pom.xml"

superpom (located in repository)
|-rootpom (located locally: no error)
|-|-parentpom (located locally: error resolving parent)
|-|-|-module1 (located locally: error resolving parent)
|-|-|-module2 (located locally: error resolving parent)
|-|-|-module3 (located locally: error resolving parent)
|-|-|-module4 (located locally: error resolving parent)

The Error...

Non-resolvable parent POM for myGroup:myArtifactId:1.0: Failure to find myGroup:myParentArtifactId:1.0 in http://myRepo.net/archiva/repository/maven2 was cached in the local repository, resollution will not be reattempted until the update interval of maven2 has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml, line x, column y -> [Help 2]

... seems to indicate that the pom was searched for in the repository, so I wonder why the pom was not found locally before looked elsewhere.

I have read that maven3 might get confused when several repositories are defined in the settings.xml, but that was always when searching for a pom inside repositories and not locally.

update

Up until now we did execute the maven build on the parent-project level (parentpom) - a fact which I did not know was important, since maven2 completed successfully until now.

When using maven3 this seems to be of importance. When executing maven3 on the root-project level (rootpom) the build finishes successfully. So my immediate problem is solved.

Since I don't necessarily want to answer my own question maybe someone can explain why maven3 behaves this way now or why the old approach was wrong.

like image 903
elfwyn Avatar asked Nov 17 '11 16:11

elfwyn


4 Answers

Make sure you Double-Check that the version you refer to in the child-pom is the same as that in the parent-pom. For me, I'd bumped version in the parent and had it as 3.1.0.0-RELEASE, but in the child-pom, I was still referring to the previous version via relativePath, and had it defined as 2.0.0.0-SNAPSHOT. It did not make any difference if I included just the parent directory, or had the "pom.xml" appended to the directory:

    <parent>        
    <artifactId>eric-project-parent</artifactId>
    <groupId>com.eric.common</groupId>
     <!-- Should be 3.1.0.0-RELEASE -->
    <version>2.0.0.0-SNAPSHOT</version>     
    <relativePath>
                ../../EricParentAsset/projects/eric-project-parent</relativePath>           
</parent>
like image 143
Eric Manley Avatar answered Nov 11 '22 08:11

Eric Manley


Here is answer to your question.

By default maven looks in ../pom.xml for relativePath. Use empty <relativePath/> tag instead.

like image 32
Ilya Silvestrov Avatar answered Nov 11 '22 08:11

Ilya Silvestrov


'parent.relativePath' points at wrong local POM @ myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml

This indicates that maven did search locally for the parent pom, but found that it was not the correct pom.

  • Does pom.xml of parentpom correctly define the parent pom as the pom.xml of rootpom?
  • Does rootpom folder contain pom.xml as well as the paretpom folder?
like image 6
Raghuram Avatar answered Nov 11 '22 08:11

Raghuram


I had the same problem. My project layout looked like

\---super
    \---thirdparty
        +---mod1-root
        |   +---mod1-linux32
        |   \---mod1-win32
        \---mod2-root
            +---mod2-linux32
            \---mod2-win32

In my case, I had a mistake in my pom.xmls at the modX-root-level. I had copied the mod1-root tree and named it mod2-root. I incorrectly thought I had updated all the pom.xmls appropriately; but in fact, mod2-root/pom.xml had the same group and artifact ids as mod1-root/pom.xml. After correcting mod2-root's pom.xml to have mod2-root specific maven coordinates my issue was resolved.

like image 2
buzz3791 Avatar answered Nov 11 '22 08:11

buzz3791