Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error during build EAR file in Maven

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>

like image 200
syril Avatar asked Oct 11 '12 10:10

syril


People also ask

What is ear file in Maven?

This plugin generates Java EE Enterprise Archive (EAR) file. It can also generate the deployment descriptor file (e.g. application. xml ).

What is ear packaging in Maven?

Enterprise application archive – or ear – is a compressed file that contains a J2EE application. It consists of one or more modules that can be either web modules (packaged as a war file) or EJB modules (packaged as a jar file) or both of them.

How do I add war inside my ear with Maven?

if you have EAR file you can unpack it: maven.apache.org/plugins/maven-ear-plugin/examples/… and then add war, change application. xml and pack it again.


1 Answers

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.

like image 164
maba Avatar answered Sep 20 '22 12:09

maba