Tuesday, November 12, 2013

Eclipse Maven Issue : 'dependencies.dependency.version' for jar is missing

Having trouble building a new Maven Project in Eclipse. I get the following exception regarding missing dependencies, even though I have added the dependency for this jar in the parent pom with a version tag.

Child pom.xml:

  <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
            </dependency>
                      ...
                      Other Dependencies
        </dependencies>

Parent pom.xml:

        <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
                <version>11.1.1.4.0</version>
                <scope>compile</scope>
            </dependency>
           
            ...
            ...
            Other Dependencies
            ...
            ...
        </dependencies>


Error:

 The project testwebapp-parent:testapp:1.0-SNAPSHOT (C:\workspace\testwebapp-parent\testwebapp\pom.xml) has 2 errors
[ERROR]     'dependencies.dependency.version' for com.oracle.jars.common:javax.ejb_3.0.1:jar is missing. @ line 18, column 15
[ERROR]     'dependencies.dependency.version' for com.oracle.jars.common:javax.jms_1.1.1:jar is missing. @ line 22, column 15


If I run it with '-N'  option in Run Configurations as shown below it works fine, but it doesn't fix the problem when I run it on remote build environment like Hudson, or if I try to directly run it.



Solution :

The fix to the problem is having a <dependencyManagement> tag in your parent POM.
I just had <dependencies> tag in my parent pom. After adding this tag it works just fine.


Parent pom.xml:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
                <version>11.1.1.4.0</version>
                <scope>compile</scope>
            </dependency>
           
            ...
            ...
            Other Dependencies
            ...
            ...
        </dependencies>
    </dependencyManagement>

No comments:

Post a Comment