error during build EAR file in Maven

syril picture syril · Oct 11, 2012 · Viewed 23k times · Source

I'm facing the followinf issue :

Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml (default-generate-application-xml) on project UserAdminEAR: Artifact[war:com.syril.administration:UserAdmin] is not a dependency of the project. -> [Help 1]

what is the solution for this kind of error?

my pom.xml is

<modelVersion>4.0.0</modelVersion>
<groupId>UserAdminEAR</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>UserAdmin</name>
<packaging>ear</packaging>
<dependencies>
    <dependency>
        <groupId>com.syril.dao</groupId>
        <artifactId>dataAccess</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.syril.service</groupId>
        <artifactId>UserAdminService</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <modules>
                    <jarModule></jarModule>
                    <javaModule>
                        <groupId>com.syril.dao</groupId>
                        <artifactId>dataAccess</artifactId>
                        <includeInApplicationXml>true</includeInApplicationXml>
                    </javaModule>
                    <webModule>
                        <groupId>com.syril.service</groupId>
                        <artifactId>UserAdminSL</artifactId>
                        <contextRoot>/UserAdminSL</contextRoot>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
</build>

Answer

maba picture maba · Oct 11, 2012

You will have to add the war as a dependency to the project too, not only in the plugin configuration.

<project ...>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.syril.administration</groupId>
    <artifactId>UserAdminEAR</artifactId> 
    <version>YOUR_VERSION_HERE</version>
    <packaging>ear</packaging>

    <dependencies>
        <!-- some other dependencies here -->
        ...
        <!-- Here is the dependency to the war that is referenced in the ear plugin -->
        <dependency> 
            <groupId>com.syril.administration</groupId> 
            <artifactId>UserAdmin</artifactId> 
            <version>YOUR_VERSION_HERE</version> 
            <type>war</type> 
        </dependency>
    </dependencies>
    ...
</project>

Edit

The <webModule/> artifact is not in your <dependencies/> list. That is what I was suggesting.

Add the following:

<dependency>
    <groupId>com.syril.service</groupId>
    <artifactId>UserAdminSL</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
</dependency>

OR

Change the <webModule/>:

<webModule>
    <groupId>com.syril.service</groupId>
    <artifactId>UserAdminService</artifactId>
    <contextRoot>/UserAdminSL</contextRoot>
</webModule>

That is of course if UserAdminService is the same as UserAdminSL which I think.