Lives in the UK. Likes blogging, cycling and eating lemon drizzle cake. Roger is a DZone MVB and is not an employee of DZone and has posted 142 posts at DZone. You can read more from them at their website. View Full User Profile

Maven's Non-resolvable parent POM Problem

03.12.2013
| 23947 views |
  • submit to reddit
I recently got an email from Nosheen Javed asking about an exception he was getting on his Maven build. The exception was:

[FATAL] Non-resolvable parent POM: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0

...which when listed in full comes out as:

Apache Maven 3.0.4 (r1232337; 2012-01-17 13:44:56+0500)
Maven home: C:\Users\Nosheen\workspace\simple-fingers-sample\EMBEDDED
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jre7
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from EMBEDDED\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\Nosheen\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\Nosheen\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\Users\Nosheen\.m2\repository
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]

org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 inhttp://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 4, column 10
 at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)
 at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
 at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR]  
[ERROR]   The project com.mycompany.samples:simple-fingers-sample:4.2.0.0 (C:\Users\Nosheen\workspace\simple-fingers-sample\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 inhttp://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 4, column 10 -> [Help 2]
org.apache.maven.model.resolution.UnresolvableModelException: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
 at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:159)
 at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:813)
 at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:664)
 at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:310)
 at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
 at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:410)
 at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:379)
 at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:343)
 at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
 at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
 at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
 at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
 at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
 at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:286)
 at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:155)
 ... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
 at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:230)
 at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:204)
 at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:427)
 ... 26 more
[ERROR] 
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

...and I thought it worth noting as its something I’ve seen several times. It generally crops up when you’re setting up a project giving you a bewildering amount of information. This is telling me that slf4j has not been setup, that the build is using Java version 1.7.0_07 from Oracle and that the Maven home is C:\Users\Nosheen\workspace\simple-fingers-sample\EMBEDDED; however, if you dissect the whole lot you can refine the problem down to the following:

[FATAL] Non-resolvable parent POM: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0 inhttp://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM

This means that the project the Nosheen is trying to get to compile has a parent project called "com.mycompany.samples:biometrics-samples:pom" and Maven can't find it.

In this case I'm assuming that the parent project "com.mycompany.samples:biometrics-samples:pom" is a MyCompany internal project that will not be stored in an external Maven repository like Maven Central.

The irritating thing about this exception is that there are a few reasons for it to be thrown which means that there are a number of things that you have to check in order to fix it.

Firstly, is the parent project in your local repository? If not there are a couple of options, like do you need to check it out and build it yourself? If you have checked it out can your project see it or do you need to add a relative path element to your project’s POM file? Something like this:

<parent>
  <groupId>com.mycompany.samples</groupId>
  <artifactId>biometrics-samples</artifactId>
  <version>1.0-SNAPSHOT</version>
  <relativePath>{path to}/mycompany-samples/pom.xml</relativePath>
 </parent>

If your company has an internal repository on some company server somewhere then do you need to add a reference to it in either of your local or global settings.xml or pom.xml files? Something like this JBoss public repository definition:

<repositories>
  <repository> 
      <id>jboss-public-repository-group</id> 
      <url>https://repository.jboss.org/nexus/content/groups/public-jboss</url> 
   <releases> 
    <enabled>true</enabled> 
   </releases> 
   <snapshots> 
     <enabled>true</enabled> 
   </snapshots> 
  </repository>
 </repositories>

If your Maven build is being accessed via Eclipse, then are your Eclipse preferences setup correctly? You may have installed a separate copy/version of Maven to the internal one supplied by Eclipse; are you using that by mistake? Check this here in your preferences:


Using the wrong one may mean that you’re using the wrong version of the global settings.xml.

The fortunate thing is that you can confirm that your Eclipse settings are okay by taking a look at the exception message above. At the top of the message you’ll see:

DEBUG] Reading global settings from EMBEDDED\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\Nosheen\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\Nosheen\.m2\repository

From this you can see that Nosheen is using the embedded Eclipse instance, taking the global settings.xml from EMBEDDED\conf\settings.xml and the user settings.xml from C:\Users\Nosheen\.m2\settings.xml. The local repository is at C:\Users\Nosheen\.m2\repository.

If you still have problems, then check out the advice given in the links at the bottom of the exception:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Finally, there are the obvious things to check like have you spelt the name of the parent project correctly?
Published at DZone with permission of Roger Hughes, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

John J. Franey replied on Tue, 2013/03/12 - 7:57am

How about: Do you need 'relativePath' specified at all?

From sonatype:

Maven assumes that the parent POM is available from the local repository, or available in the parent directory (../pom.xml) of the current project. If neither location is valid this default behavior may be overridden via therelativePath element. For example, some organizations prefer a flat project structure where a parent project’spom.xml isn’t in the parent directory of a child project. It might be in a sibling directory to the project.

When you have a multi-module project and you want to structure your folders so the folder of the parent is a sibling of the folder of the modules, you must have a relativePath.

In other cases, relativePath is unnecessary.

1) for a single module project: install or deploy the parent artifact, and omit the relativePath property.   Specifying a relativePath sets up a dependency on the directory structure which must be satisfied by an outside script or manual step.

2) for a multi-module project and you want to structure your folders so the folder of the  parent is in the parent folder of the modules, then you can omit relativePath from the modules, for that is the maven default convention.


Mladen Girazovski replied on Sat, 2013/03/16 - 5:24am

 If your company has an internal repository on some company server somewhere then do you need to add a reference to it in either of your local or global settings.xml or pom.xml files?

Repository declarations in Poms are only acceptably for OSS Projects in general. For a non-OSS Project this is in 99% of the cases a no-go.

Btw., if the company does not have a Repo Manger like Nexus or Artifactory yet, it needs to setup one. You can't do proffessional Java development using Maven as build tool without one.

I consider changing the global settings.xml as dirty hack, only in a few exceptional cases it is  acceptable, temporarly.

Just use the "normal" settings.xml the way it was intended:

  • define repositories
  • define a mirror to make sure every request is routed through your Repository Manager, this will overrride repositories declared in Poms, unless the repository is explicitly excluded from the mirror
This will ensure everything necessary to repeat a build is held in-house.

Now about your error, you can and should use the Enforcer Plugin ("The Loving Iron Fist of Maven") to have your build fail-fast in case the wrong Repositories/Java Version/Maven Version is used, saves you time that you'd otherwise need to find problems like this.

Apart from that, the enforcer plugin can do a whole lot more for you, like break the build if your have one or more Dependency  Convergences, which means your Dependencies are not really managed.


Btw., since JBoss screwed up their Repo so badly, i try to avoid it compeltely.

Thiago Nascimento replied on Mon, 2014/02/03 - 2:45pm

 In my case the <relativePath/> worked. Thanks, Roger! It has been an excelent post.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.