Issue Details (XML | Word | Printable)

Key: MNG-1562
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Critical Critical
Assignee: John Casey
Reporter: Arik Kfir
Votes: 4
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Maven 2 & 3

Exception with dependencies that have <type> and implied <version> from parents

Created: 14/Nov/05 03:03 PM   Updated: 26/Jul/06 05:03 PM   Resolved: 26/Jul/06 05:03 PM
Component/s: Inheritance and Interpolation
Affects Version/s: 2.0
Fix Version/s: 2.0.5

Time Tracking:
Not Specified

Environment: JDK 1.5.0_05, Kubuntu Linux 5.1

Complexity: Intermediate


 Description  « Hide

I have the following POM structure:

POM_PARENT
+--POM_EJB (packaging=ejb)
+--POM_EAR (packaging=ear)

As you can see, POM_EJB and POM_EAR extend POM_PARENT.

The POM_PARENT defines a "<dependencyManagement>" which specifies the correct version of POM_EJB that POM_EAR should depend upon, like this:
<dependencyManagement>
...
<dependency>
<groupId>...</groupId>
<artifactId>POM_EJB</artifactId>
<version>...</version>
</dependency>
</dependencyManagement>

POM_EAR contains the following:
<dependency>
<groupId>...</groupId>
<artifactId>POM_EJB</artifactId>
</dependency>

This works well, until I use the maven-ear-plugin to package the POM_EAR project. I get the error:

Artifact[org.corleon.crm:crm-ejb-dummy:ejb] is not a dependency of the project.

Note the ":ejb" at the end of the artifact ID. I've poked around the maven-ear-plugin and I see it makes sure that EJB modules' for the application.xml are indeed of TYPE ejb, which is fine. However, when I add the "<type>ejb</type>" clause to the POM_EAR's dependency (either in the depManagement in POM_PARENT or in POM_EAR itself) I get the exception:

arik@corleon:~/projects/crm/ear$ mvn package
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ----------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.corleon.crm:crm-ear
POM Location: /home/arik/projects/crm/ear/pom.xml
Validation Messages:

[0] 'dependencies.dependency.version' is missing.

Reason: Failed to validate POM

[INFO] ----------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:359)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:276)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:113)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to validate POM
at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:774)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:624)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFile(DefaultMavenProjectBuilder.java:298)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:276)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:509)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:441)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:345)
... 11 more
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Nov 14 22:58:26 IST 2005
[INFO] Final Memory: 1M/2M
[INFO] ----------------------------------------------------------------------------

This happens anytime there's a dependency that has a <type> clause without a <version> clause (even though the <version> should be taken from a <dependencyManagement> clause in the parent POM).



Brett Porter added a comment - 22/Nov/05 08:16 PM

what if you put the <type> in the <dependencyManagement> element too?


Arik Kfir added a comment - 25/Nov/05 01:49 PM

Then I get this (error relates to POM_EAR):

arik@corleon:~/projects/crm/trunk$ mvn clean package
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ----------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.corleon.crm:crm-ear
POM Location: /home/arik/projects/crm/trunk/ear/pom.xml
Validation Messages:

[0] 'dependencies.dependency.version' is missing.

Reason: Failed to validate POM

[INFO] ----------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:359)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:276)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:113)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to validate POM
at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:774)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:624)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFile(DefaultMavenProjectBuilder.java:298)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:276)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:509)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:441)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:485)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:345)
... 11 more
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Nov 25 21:47:35 IST 2005
[INFO] Final Memory: 1M/3M
[INFO] ----------------------------------------------------------------------------

The EAR pom now has only a groupId and an artifactId, where the parent POM defines the group, artifact, type and version.


Siarhei Dudzin added a comment - 25/Dec/05 04:42 PM

Confirming the issue. Both <type/> and <version/> for POM_EAR (in this example) MUST be present which makes <dependencyManagement/> in parent POM_PARENT project obsolete/broken (and the documentation on http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html as well).


Stephane Nicoll added a comment - 27/Dec/05 02:26 PM

Let's increase the priority of this one.


John Casey added a comment - 26/Jul/06 05:03 PM

in the case of non-jar dependencies, the minimal set of information for dependencies referencing an entry in the dependencyManagement section is groupId:artifactId:type[:classifier]. This allows the dependencyManagement section to house information on multiple dependencies from the same POM, with different types and potentially different classifiers.

Again, the identity used to match dependencies against the dependencyManagement section is:

groupId:artifactId:type='jar'[:classifier]

So, in this case, you'd use:

<dependency>
<groupId>...</groupId>
<artifactId>POM_EJB</artifactId>
<type>ejb</type>
</dependency>

in order to reference the information stored in your <dependencyManagement/> section. I've updated the site documentation to reflect this, and will republish within the next few minutes.