156

I have my maven project setup as 1 shell projects and 4 children modules. When I try to build the shell. I get:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR] The project module1:1.0_A0 (C:\module1\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find shell:pom:1.0_A0 in http://nyhub1.ny.ssmb.com:8081/nexus/content/repositories/JBoss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]

If I try to build a lone module I get the same error only replace module1, with whatever module it was.

Have them all referencing the parent in their poms.

<parent>
    <artifactId>shell</artifactId>
    <groupId>converter</groupId>
    <version>1.0_A0</version>
</parent>

Here is the relevant parts of the shell pom:

<groupId>converter</groupId>
<artifactId>shell</artifactId>
<version>1.0_A0</version>
<packaging>pom</packaging>
<name>shell</name>


<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
    <module>module4</module>
</modules>
5
  • 2
    if anyone is interested, adding <relativePath>..</relativePath> under <parent></parent> worked for me.
    – kaptan
    Commented Jan 23, 2019 at 1:31
  • 3
    run this mvn install -N & mvn install
    – Se Song
    Commented Aug 29, 2019 at 10:05
  • 1
    Relative path is for non-conforming projects not a "solution" when the expectation is a pom in the parent folder of the module should be accessible. Commented Nov 6, 2019 at 23:04
  • In my case it was because of the mistyping in pom.xml file. Commented Apr 2, 2020 at 20:31
  • I tried to install mvn install but terminals says The term 'mvn' is not recognized as the name of a cmdlet, function, script file, or operable program.
    – Manghud
    Commented Dec 2, 2020 at 8:39

23 Answers 23

135

Just for reference.

The joys of Maven.

In the pom.xml of the child modules, setting the relative path of the to ../pom.xml solved it.

The parent element has a relativePath element that you need to point to the directory of the parent. It defaults to ..

<parent>
    <artifactId>shell</artifactId>
    <groupId>converter</groupId>
    <version>1.0_A0</version>
    <relativePath>..</relativePath>   <!-- THIS -->
</parent>
5
  • 22
    Yes. Using Maven requires that you know what you do, trial and error won't get you very far. On the other hand there are several good references available. This is one. Commented Sep 30, 2011 at 15:46
  • 9
    So you added this <relativePath>..</relativePath> under <parent></parent> ?
    – bsky
    Commented Jan 4, 2017 at 18:43
  • 1
    Thanks I tried it for a while to solve the problem. I took the relative path from ../pom.xml to ../<parent folder>/pom.xml. Commented Feb 4, 2017 at 19:36
  • 2
    Putting the <relativePath> would not necessary solve the problem if you are pointing to a private repository. Look down for Tomáš Záluský response for detail explanation.
    – Gi1ber7
    Commented Aug 15, 2018 at 18:50
  • I'm trying to extend my main pom file to another one (for tests) in the same directory (same project). But this doesn't solve this error. Any idea how to fix it? Commented Apr 5, 2019 at 9:26
58

It can also be fixed by putting the correct settings.xml file into the ~/.m2/ directory.

3
  • 4
    Exactly that solved my problem, thanks!!! But not by putting it into some directory, but pointing Eclipse to it in Preferences - Maven - User Settings.
    – Brain
    Commented Oct 4, 2017 at 13:44
  • Solved my problem too. Just have to make sure the settings are properly configured to maven.repo too..
    – Saran
    Commented May 9, 2018 at 0:35
  • I removed the stting.xml file and fixed. Commented Apr 14, 2021 at 11:28
29

Alternative reason also might be the parent artifact comes from repository which is not accessible from pom.xml, typically private repository. The solution was to provide that repository in pom.xml:

<repositories>
    <repository>
        <id>internal-repo</id>
        <name>internal repository</name>
        <url>https://my/private/repo</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

In my case the problem was even more complicated due to Eclipse: the repository was active only in special profile (<profiles><profile><id>activate-private-repo</id><repositories>...) and Maven GUI in Eclipse didn't allow to set this profile through Ctrl+Alt+P shortcut.

The solution was to temporarily declare repository outside profile (unconditionally), launch Alt+F5 Maven Update Project, activate profile and put repository declaration back into profile. This is rather Eclipse bug, not Maven bug.

2
  • Same situation!private repo not added to the pom. Commented Jan 25, 2018 at 7:21
  • This and @user1747134 answers are correct. This answer addresses the root cause and the use of settings.xml may be necessary where mirrors or servers authn and authz are factors of the environment.
    – javafueled
    Commented Jan 15 at 19:11
9

Just add <relativePath /> so the parent in pom should look like:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath />
    </parent>
1
  • 5
    This only applies when the parent is not in the same dir structure, i.e. in a remote repository. Commented Aug 11, 2019 at 8:17
7

Non-resolvable parent POM: This means you cannot resolve the parent repo.

Trun on debug mode:

[DEBUG] Reading global settings from **/usr/local/Cellar/maven/3.5.4/libexec/conf/settings.xml**
[DEBUG] **Reading user settings from /Users/username/.m2/settings.xml**
[DEBUG] Reading global toolchains from /usr/local/Cellar/maven/3.5.4/libexec/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/username/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/username/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/username/.m2/repository
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:

Because the parent repo is not part of the maven central. The solution is specify a setting.xml in ~m2/ to help result the parent POM. /Users/username/.m2/settings.xml

In that XML, you might need to specify the repository information.

2
  • Awesome ! Adding my repo details in settings xml worked. But why it's not taking from the pom xml (which has the same repo added in it) ?
    – smilyface
    Commented Dec 18, 2018 at 13:25
  • 3
    What kind of details? Can you describe? Commented Apr 15, 2021 at 14:14
4

<relativePath>

If you build under a child project, then <relativePath> can help you resolve the parent pom.

install parent pom

But if you build the child project out of its folder, <relativePath> doesn't work. You can install the parent pom into your local repository first, then build the child project.

1
  • but don't we need to build the child before a build and install of the parent will succeed? Isn't there a chicken/egg problem here?
    – Cheeso
    Commented Apr 13 at 0:02
4

In addition to the answer by Luke Willis, looks like this:

<parent>
    <groupId>com.example</groupId>
    <artifactId>some-module</artifactId>
    <version>1.0</version>
    <relativePath>../pom.xml</relativePath>
</parent>
3

It was fixed when I removed settings.xml from .m2 folder.

1
  • 2
    How did you fix? What did you do, do you remember? Commented Apr 15, 2021 at 14:06
2

verify if You have correct values in child POMs

GroupId
ArtefactId
Version

In Eclipse, for example, You can search for it: Eclipse: search parent pom

2

I had the following config in the parent pom:

  <properties>
    <revision>1.0-SNAPSHOT</revision>
  </properties>

  <groupId>com.company.org</groupId>
  <artifactId>api-reactor-pom</artifactId>
  <version>$revision</version>
  <packaging>pom</packaging>

And I was getting 'Non-resolvable parent POM' error. I changed version to <version>1.0-SNAPSHOT</version>, and it's gone.

Apache Maven 3.6.3.

1
  • This was my issue. Looks like a bug to me, but you can't use ${revision} as the version of the parent (even in Maven 3.8.4), and have it resolved locally. Commented Mar 6, 2023 at 23:46
2

In this case the parent artifact is not found. As others pointed out, adding <relativePath/> to the pom where you reference a parent that cannot be found locally may work. But why does it work?

If the parent POM is not located in the parent folder, we need to use the relativePath tag to refer to the location. ... To skip the local file search and directly search the parent POM in Maven repositories, we need to explicitly set the relativePath to an empty value

as they explained here.

In other cases it will not work because the real reason is that Maven is unable to find the settings.xml which specifies the repositories to check for the parent artifact. E.g. when you try to build your Maven project from WSL2 (Linux shell on Windows) where you have not set up your Maven configuration.

In that case you need to create the settings.xml in the .m2 directory of WSL2 or create a reference to it, e.g. via a symbolic link. (That is a different issue but could be solved like this.)

2

Replace <version>1.0_A0</version> with <version>${project.version}</version>

Run mvn once. This will download all the required repositories. You may switch back to 1.0_A0 after this step.

1
  • 1
    This only works if the required parent POM has the same version as the sub-module's POM. This is not always the case. Commented Feb 9, 2018 at 20:14
1

I had similar problem at my work.

Building the parent project without dependency created parent_project.pom file in the .m2 folder.

Then add the child module in the parent POM and run Maven build.

<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
    <module>module4</module>
</modules>
1
  • Your answer, together with <relativePath/> solved the problem for me. *relativePath alone did not. Commented Sep 2, 2020 at 10:35
1

In my case, moving the correct settings.xml file in the "conf" folder of the maven installation folder has solved the problem.

1

This error occurred for me after I refactored a project, moving what had been the root module and using spring-boot-starter-parent as its parent to instead making it a child of a new root module.

In my case, I just needed to remove <relativePath/> from the parent section of the former-root-now-child module.

1
  • 12 years on the struggle is real thanks for posting an updated answer for those using spring boot
    – Will
    Commented Jun 7 at 23:16
0

I solved that problem on me after a very long try, I created another file named "parent_pom.xml" in child module file directory at local and pasted contents of parent_pom.xml,which is located at remote, to newly created "parent_pom.xml". It worked for me and error message has gone.

0

Inside relative path tag do as follows

<relative>{project_name}/pom.xml</relative>

and then RunAs-> Maven build

It worked for me.

1
  • 2
    Where did you locate the relative? relative between relativePath is not allowed Commented Apr 15, 2021 at 14:08
0

I had this issue, the version of the parent pom.xml was not the same as the child's ones after an upgrade.

I Fixed it by setting the same version number for the parent and it's childs.

0

I encountered a similar problem.

Project build error: Non-resolvable parent POM for com.in28minutes.microservices:limits-service:0.0.1-SNAPSHOT: org.springframework.boot:spring-boot-starter-parent:pom:3.2.0-M3 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. 
This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM

I tried many things and eventually decided to manually verify if the 3.2.0-M3 dependency is present in repo - https://repo.maven.apache.org/maven2 . Turns out it wasn't. I switched the dependency to 3.1.4 which I found was present on the repo. This solved my issue.

0

I have changed my internet to mobile network and update maven repo. Including setting of download javadoc something from preferences->maven and it worked for me.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 13 at 8:17
0

Based on your directory structure, relative path will fix this problem.

Let us consider we have two module and assume directory structure as :

   - example-project
      - example-app-backend
        - pom.xml
      - example-app-frontend
        - pom.xml
      - pom.xml

Module 1 : (project/example-app-backend/pom.xml)

 <parent>
        <groupId>com.example</groupId>
        <artifactId>example-app-backend</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
 </parent>

Module 2 : (project/example-app-frontend/pom.xml)

 <parent>
        <groupId>com.example</groupId>
        <artifactId>example-app-frontend</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
 </parent>

Project :

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>

      <!-- replace with your project related ...-->

        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.13</version>
        <relativePath/> <!-- lookup parent from repository -->
        
      <!-- replace with your project related ...-->

    </parent>

    <groupId>com.example</groupId>
    <artifactId>demo-application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Maven multi module setup</name>

    <modules>
        <module>example-app-backend</module>
        <module>example-app-frontend</module>
    </modules>
    <properties>
       <!-- replace with your project related ...-->
    </properties>

</project>
-2

I had the issue that two reactor build pom.xml files had the same artefactId.

1
  • In my case, this parent module was not in the parent folder, I had to add in the child module <relativePath>../parent-module-dir</relativePath> Commented Oct 30, 2018 at 14:01
-2

Add a Dependency in

pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.8.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
</dependency>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.