pom.xml Can't resolve parent? - java

I am a "noob" with maven and I am running a mvn clean install for a open source project I found. I am trying to get it to build a jar file. When I run it the way it "supposedly" is going to work. I get this error...
Non-resolvable parent POM: Could not find artifact
com.gorillalogic.monkeytalk:monkeytalk:pom:1.0.12-SNAPSHOT and 'parent.relativePath'
points at wrong local POM # line 6, column 10 -> [Help 2]
For the pom.xml file # line 6-10 I have...
<parent>
<groupId>com.gorillalogic.monkeytalk</groupId>
<artifactId>monkeytalk</artifactId>
<version>1.0.12-SNAPSHOT</version>
</parent>
Is there a step I am missing? I can give more code if you need it?
Thanks in advance!

You are missing the parent projects pom.
Most likely your folder structure looks like this:
.../moneytalk_Foo/pom.xml
.../moneytalk_Foo/someFolder
but it should look like this:
.../pom.xml
.../moneytalk_Foo/pom.xml
.../moneytalk_Foo/someFolder
Or that parent is a project into itself and you must download it and call mvn install on it yourself.

the parent project maybe not installed yet, try run the parent project "monkeytalk" as Maven install.

Not sure if this is a cure all for everyone seeing this, but for me it was because my maven settings.xml file was not being found. Maven uses this file to locate remote repos for downloading SNAPSHOT files so if it can't find the settings.xml file then parent.relativePath is essentially undefined. Pretty crappy error message for this IMO, it should dump the value of parent.relativePath to give some indication of an undefined var.

Related

Missing Maven Dependency on Locally installed atrifact

I have a .jar file, which I want to use in my current project which I am building with Maven. After some research I figured out that I need to install it locally. This I did using:
mvn install:install-file -Dfile="D:\Eclipse Workspace\TextOnlyJam\adapterLib\lwjgladapter.jar" -DgroupId=lwjgladapter -DartifactId=lwjgladapter -Dversion=1.0 -Dpackaging=jar`
I then added the dependency into my pom like so:
<dependency>
<groupId>lwjgladapter</groupId>
<artifactId>lwjgladapter</artifactId>
<version>1.0</version>
</dependency>
My project in exclipse now manages to resolve all dependencies and does not give me any compile errors. However after cleaning and updating my maven project several times, I still get the following error when running an install:
Failure to find lwjgladapter:lwjgladapter:jar:1.0 in https://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
I assume that maven is looking for the artifact in the wrong location, however I can not figure out what I need to change here.
(I am also not sure if I need to add the dependency into , since it does not seem to change anything when I do.)
Okay, I just figured out that it was just a stupid mistake on my end. I looked into the repository folder and found, that my jar file was named `.jar``
So yeah, a simple copy and past error. Thanks for the help so far!

Maven building working from command prompt, but not from Eclipse

I found this crazy issue in my eclipse. I'm able to run the Maven build with the command "maven clean package" in command prompt. But however when I try to build the same in eclipse by doing right click-> run as -> Maven build, In the configuration I've added as "clean package". It is throwing me the error of
The project com.svu.core:cUT:1.0.0-SNAPSHOT (E:\CU-SVN\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find com.zenmonics.core:epom:pom:1.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 and 'parent.relativePath' points at wrong local POM # line 11, column 10 -> [Help 2]
It has the same error in POM.xml, but how is it running from command prompt but not from eclipse IDE. Due to this I'm not able to get Maven dependencies in my Build path.
<project xmlns="http://maven.apache.org/POM/4.0.0" x mlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <groupId>com.svu.core</groupId>-->
<artifactId>cUT</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>pom :: cUT</name>
<packaging>pom</packaging>
<parent> <---------- Here it throws error
<groupId>com.svu.core</groupId>
<artifactId>epom</artifactId>
<version>1.0.0</version>
</parent>
You might be using embedded maven inside eclipse.
You can try using the same maven set up that you are using on your system.
go to -->
Window >> preferences >> maven >> installations
Here in - add a new installation and give the path till bin folder of maven libraries.
Try using this approach - it should work , if your maven commands are working fine from command prompt.
Please check your workspace whether maven repository exist or not exist..!
Please try to put your pom.xml. Your error says that the problem is in pom.xml # line 11, column 10. The problem is the parent pom is not detected in your current pom. Try the following
<project>
<parent>
<groupId>com.svu.core</groupId>
<artifactId>epom</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.svu.core</groupId> <--- Same group id as your parent
<artifactId>cUT</artifactId>
Reference: http://maven.apache.org/guides/introduction/introduction-to-the-pom.html
Note: I dont have enough reputation to comment in your question.
When following is working
cd cUT
mvn compile
but the same module cannot be compile in Eclipse. Probably you have changed the Maven config and the Eclipse view of it is not up-to-date anymore. This can happen for exmaple if you change a pom.xml file outside Eclipse or at a place which is not considered as to be in the project path (see your other question).
Select in the Project Explorer in Eclipse the module cUT. Press ALT-F5 (executes maven -> update project). Select all modules of your project, check that update project configuration from pom.xml is enabled and click on òk` to process.
I had the same exact problem, everything was working on eclipse Mars, but I switched to Eclipse Oxygen and all my variables were fine, I checked everywhere.
And suddenly I got into the preferences in eclipse for Maven Installations (where you point to the Maven directory) and just got rid of the forward slash at the end of the path and it worked!
Basically:
Change C:\Program Files\apache-maven_3.5.3\
to
C:\Program Files\apache-maven_3.5.3
And it worked!
The difference between building from command line and eclipse is the variables. Like:
the java path in case you have more than one jdk. The command line will pick from java home where as in eclipse you can configure which jdk to use.
settings.xml can also be different. I think this is the problem in your case. Command line picks the settings.xml from the source code directory (if present). This file contains the maven repo url to download all the dependencies. In eclipse you can configure the path for settings.xml. I suspect the path is different in eclipse compared to command line. Please change that in eclipse and it should work. I have faced this issue and this was the root cause. you can see in your logs "Failure to find com.zenmonics.core:epo, which suggests the some problem in the repo url.
I have installed latest maven and in the windows -> maven -> installation I have added my latest maven. It started working for me.

maven dependency issue with parent-child reference

I am using apache maven 3.1.0 (after quite some time) on windows for a project put together by somebody else. I have a parent pom & multiple child pom xml files. The child pom contains the following which is causing an issue when I run mvn clean install:
<parent>
<groupId>com.test.platform</groupId>
<artifactId>test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
The error I get from mvn -e points to a dependency issue due to inability to find the artifact (referring to the 0.0.1-SNAPSHOT). I am not sure if I am missing a step or need to change something with my project/pom xml files. Any useful suggestions would be welcome (I can post more detailed error messages if needed). Thanks!
Update:
I have also tried adding a relative path to the child pom xml file though its still giving me an error.
Directory Structure:
Main Directory -> pom.xml file
Child Directory -> pom.xml file (with parent tag) - I added the relative section to it as well.
Interesting that the Introduction to the POM shows the relativePath as pointing directly to the pom.xml file, whereas the POM reference shows the relativePath pointing to the parent module/project, and not to the pom. Perhaps it supports both, but I can tell you that the project I'm looking at now (which works) has <relativePath>../myParentProject</relativePath>
Perhaps you could try to set the relative path in your project to ../
Of course, this all assumes that the answer to the question of whether 0.0.1-SNAPSHOT of the parent actually exists in your repository is YES.

Maven finds artifact but cannot compile

When I run a mvn compile I get a list of errors from the compilation that all say a package is missing that I have as a dependency in my pom.xml.
Pom.xml
`<dependency>
<groupId>com.fortysevendeg.android</groupId>
<artifactId>swipelistview</artifactId>
<version>1.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>`
Error
error: package com.fortysevendeg.swipelistview does not exist
I would really appreciate some help on this one. I have been banging my head against this for a while now.
Looks like MVN is not able to pull your package ( com.fortysevendeg.swipelistview ) from your repository. To figure out, I would check-out the package from code repository ( i.e SVN, GitHub ) to your work space. Recheck the pom.xml for exact name & do MVN install.
link: Read
Downloading from a Remote Repository
Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer).
By default, Maven will download from the central repository.
During MVN compile it look first in your local workspace & if doesn't find then it will pull it from repository configured to.

Maven can't find parent POM

I am trying to build a maven project, but I have encountered problem.
pom has specified parent pom and maven can't find it. I actually have the parent pom, but I don't know where to place it or what should I do so maven knows about.
I'm new to maven so sorry if my question is stupid.
If you have the parent pom, you could try installing it.
When you run mvn install on a module the resulting artifact will be placed in your repository, so that it can be used from other modules.
I am using Netbeans, I ran -N versions:update-child-modules in Run Maven/Goals.
It worked! It took 5 minutes to build but, it did build the project, and that's the first time that it has.
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html Example 1 and Example 2 are for Inheritance that can be usefull.
This happens when the different POM in the project. They do not have the same version.
For example if you have:
MyProject / EAR ..... MyProject / WEB .....
you need to have the same version in three POM
Same error for me.I resolved by updating the project with a new POM file(someone form my team accidently deleted it).

Categories

Resources