59

This question is outdated and no longer relevant. I have since moved to Gradle for my project build and can no longer verify that answers do or do not work.

I've run into a few issues with Maven. Let me first describe my project setup:

Framework
|  -- Apache Commons Math 3.0
|  -- Bouncy Castle 1.5
|  -- etc.. (lots more)
|________
|        Client
|        | -- GUI libraries
|        | -- etc.
|
|________
         Server
         | -- Server Libraries
         | -- etc.

So essentially I have a framework that contains most dependancies and then two projects, "Server" and "Client" that contain their own BUT also the framework as a dependancy (being a module of Framework.). I installed the Framework project into my local repository and both my projects can see the Framework-Native code (aka my own logic). HOWEVER they don't seem to be able to use any of the dependancies of the Framework Project. When trying to build either of the "child"-projects I get this:

Invalid POM for de.r2soft.empires.framework:Framework:jar:Alpha-1.2, 
transitive dependencies (if any) will not be available, 
enable debug logging for more details 

I've tried to find the reason behind this (or better yet a solution) but haven't found anything that fixed my issues. Hope someone here can help. My maven version seems to be 3.2.1 (that's what -version tells me anyways)

Here are my framework-pom.xml and the client-pom.xml on pastebin:

Framework: http://pastebin.com/cceZECaT

Client: http://pastebin.com/1Cuxve5F

Help is appreciated.

AreusAstarte
  • 1,958
  • 2
  • 17
  • 29
  • As far as I remember *Invalid POM for de.r2soft.empires.framework:Framework:jar:Alpha-1.2, transitive dependencies (if any) will not be available, enable debug logging for more details* is a WARN message, so try following what is suggested and run the maven phase in debug mode to have relevant information. This can be done with `-X` option. – tmarwen May 10 '14 at 14:00
  • Well...I ran it with --debug on, yes. Wrote the output to a textfile. Check it out on pastebin here: http://pastebin.com/GZdMfWnj From what I can tell it's nagging about the jar I added manually? But if not like that...how am I supposed to add it? :/ (So that my colleagues can use it as well and not have to go to console and install 100 things)? – AreusAstarte May 10 '14 at 14:22
  • @AreusAstarte did you find a solution for this? I an facing the same problem. I am having a dependency defined as system scope. – rahul Aug 01 '14 at 09:16

10 Answers10

54

One reason for this is when you rely on a project for which the parent pom is outdated. This often happens if you are updating the parent pom without installing/deploying it.

To see if this is the case, just run with mvn dependency:tree -X and search for the exact error. It will mention it misses things you know are in the parent pom, not in the artifact you depend on (e.g. a jar version).

The fix is pretty simple: install the parent pom using mvn install -N and re-try

Omri Spector
  • 2,431
  • 24
  • 22
  • 1
    Thank you so much for this, I was pulling my hair out trying to get this to work and this solved it! – CCSab Jul 28 '17 at 02:38
  • True, mine is the same even I built the module individually and by the order, the parent pom must be built first. – MewX Apr 11 '18 at 03:37
  • 3
    What -N switch do? – Meena Chaudhary Apr 03 '19 at 09:33
  • 2
    -N will build a project WITHOUT building it's sub-modules. So in the case of "mvn install -N", you will install the parent pom without trying to build it's children too (thus avoiding a circular dependency) – Omri Spector Apr 05 '19 at 06:49
  • SOLUTION (For me): `mvn dependency:tree -X` output included WARNINGs like the original question, but also FATALs like: `[FATAL] Non-readable POM /Users/me/.m2/repository/org/eclipse/jetty/toolchain/jetty-toolchain/1.7/jetty-toolchain-1.7.pom: input contained no data @ `. So I `rm -rf ~/.m2/repository/org/eclipse/jetty` then `mvn clean compile` ...which re-downloaded the need files -- and it's been fine ever since. – DouglasDD Mar 21 '23 at 13:19
24

I had a similar error, In my case remove all related artifacts from the local repository was the workaround...

LCoelho
  • 2,951
  • 1
  • 16
  • 13
10

Remove repository folder inside .m2 and launch mvn clean install.

Keep us informed by the result and Good luck

Anas Lachheb
  • 441
  • 4
  • 17
  • 2
    This did it for me. Sometimes apparently there will be corrupted files when they download to the local .m2 repo – DPM Sep 26 '17 at 09:50
  • 1
    This did not solve the issue for me. I had to restore my .m2 folder. – Rocologo Apr 01 '18 at 14:21
4

I have the same kind of issue and I may have the answer. I have a top level project MyProject and Module1 and Module2. Module2 depends on Module1 and the entry is listed as a (default) dependency. MyProject

<modules>
Module1
Module2
</modules>

mvn dependency:tree from the folder of MyProject is OK: module2 depends on module1

MyProject
---
com.acme:Module1:version
---
com.acme:Module2:version
+com.acme:Module1:version

The problem is if I run mvn dependency:tree inside the Module2 folder. I then get the error message:

The POM for com.acme:Module2:version is invalid, 
transitive dependencies (if any) will not be available

After a few investigations I have discovered that the pom file created/copied by the install part of the build as m2/com/acme/myproject/Module1/version/Module1-version.pom is the original pom file. This one uses variables for versions as (duplicated in many other modules not listed here) or a system path (no choice to have a system dependency). These variables are defined in the parent POM file. If I replace all the ${} in the module pom file by their values then everything is fine. Basically when building the whole thing, the values of the variables are available to all the dependent modules as this is the same process. When you build an individual module the variables defined in the parent POM are not available.

Your own framework pom file contains a variable for the systempath of net.sf.javaml. Hardcode the variable or find another solution like a bill of material. https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

Olivier D
  • 423
  • 3
  • 10
  • Do you have any variable in the failing POM file where the variable is not defined in the same POM file? If yes, this can be the issue. – Olivier D Oct 13 '14 at 15:36
  • No, I took out the variables and nothing changed. Mysteriously this problem disappeared for some other reason and I can't figure out why. – 2rs2ts Oct 14 '14 at 00:34
4

Assuming that the client and server projects poms are invalid because of unsatisfied expansion, then the following should work... If the "client" and "server" projects have their dependency on "Framework" defined in a tag, then you can first install "Framework" using the -N option. First, cd to the Framework directory, then: mvn -N clean install The -N option tells maven to only install the root pom in the local repo and to skip the child modules. Now cd to your child project and rerun your install command in your client or server module. The client or server build should now find the parent pom with the properties that it needs in the local repo.

You can get the same effect by making an explicit file path reference using the relativePath tag in your child pom's parent tag:

<parent>
  <relativePath>../my-parent</relativePath>
</parent>
D Drummond
  • 41
  • 2
2

The the Framework artifact available in your local repository before running an install on the client project because there is no coupling between the two projects (the client artifact is not a module of your Framework project).

So to solve the issue you should run mvn install on your Framework project so the packaged jar is copied to your local repository. Then it is up to maven to discover and find it when you run some maven phase on the client project.

To have your artifacts shared among your organization you should deploy your artifacts (upload) to a nexus hosting mirror.

Gijs Overvliet
  • 2,643
  • 3
  • 28
  • 35
tmarwen
  • 15,750
  • 5
  • 43
  • 62
  • 1
    Noep, sorry. THis doesn't do anything. As I said, Framework is installed in the local repository and my Client project can see all the Framework native code. It just can't access the libraries that are dependancies of Framework. – AreusAstarte May 12 '14 at 16:13
  • Which scope do the Framework project dependencies have? – tmarwen May 12 '14 at 16:19
  • Most fo them are the default scope and one local jar is scope "system" – AreusAstarte May 13 '14 at 18:01
0

I had the same issue. I am managing all the modules that were referenced by the project that i was trying to build. And the problem turned out that i had to do "mvn deploy" on all the parent projects of the module that was showing this error when using in another modules pom.xml. Here is the whole explanation http://programtalk.com/java/i-used-to-get-this-maven-error-all-time/

awsome
  • 2,143
  • 2
  • 23
  • 41
0

You must to send output to log file with this command:

mvn clean install --log-file C:\XXXX\Maven\log.txt

open log.txt and analize what dependencies are not found or pom.xml are in not valid state

remove pom's that are not valid and re run mvn clean install

that is all.

0

In my case maven corrupted one of transitive dependency pom (double content), so I just removed it in my m2 folder. -X key helped me to find the certain broken pom.

0

For me the pom.xml contents load from a repository to the .m2 folder and the contents of the file when I opened was HTML content which was the reason why I was getting this WARNING message because the site was moved to a different repository location,

[WARNING] The POM for GROUPID:ARTIFACTID:PACKAGIN:VERSION is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

So I modified the pom.xml contents to,

<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>
  <groupId>GROUPID</groupId>
  <artifactId>ARTIFACTID</artifactId>
  <version>VERSION</version>
  <packaging>PACKAGIN</packaging>
</project>

Now if I run mvn clean install on the module which had the above dependency the warning din't show. So check the contents of the pom.xml.

Lucky
  • 16,787
  • 19
  • 117
  • 151