Aravind
Aravind

Reputation: 1255

application.xml does not exist. error during maven EAR build

I am trying to build an ear project with two war files inside. While building the EAR I am getting the error as "application.xml does not exist". But I have placed the application.xml in the projects META INF folder. Please find the code below. and suggest a solution to resolve this.

Below Is my POM.XML

<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>au.com.mercury</groupId>
  <artifactId>ReplenishmentR4</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
  <build>
  <plugins>
    <plugin>
      <artifactId>maven-ear-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <applicationXML>src/main/application/META-INF/application.xml</applicationXML>
        <generateApplicationXml>false</generateApplicationXml>
        <encoding>UTF-8</encoding>
        <defaultLibBundleDir>lib/</defaultLibBundleDir>
        <filtering>true</filtering>
        <modules>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>Replenishment</artifactId>
            <bundleFileName>Replenishment.war</bundleFileName>
          </webModule>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>ReplenishmentR3</artifactId>
            <bundleFileName>ReplenishmentR3.war</bundleFileName>
          </webModule>
        </modules>
      </configuration>
    </plugin>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
  </plugins>
   <finalName>ReplenishmentR4</finalName>
</build>

<dependencies>

  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>Replenishment</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>ReplenishmentR3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  </dependencies>
</project>

Below is my application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <module>
    <web>
      <web-uri>Replenishment.war</web-uri>
      <context-root>/Replenishment</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>ReplenishmentR3.war</web-uri>
      <context-root>/ReplenishmentR2</context-root>
    </web>
  </module>
</application>

Open This Image for the project structure.

Project structure

Maven build console error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ReplenishmentR4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for au.com.woolworths.mercury:ReplenishmentR3:war:0.0.1-SNAPSHOT is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ReplenishmentR4 ---
[INFO] Deleting C:\Users\xagh9\workspace\ReplenishmentR4\target
[INFO] 
[INFO] --- maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) @ ReplenishmentR4 ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ReplenishmentR4 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\xagh9\workspace\ReplenishmentR4\src\main\resources
[INFO] 
[INFO] --- maven-ear-plugin:2.6:ear (default-ear) @ ReplenishmentR4 ---
[INFO] Copying artifact[war:au.com.mercury:Replenishment:0.0.1-SNAPSHOT] to[Replenishment.war]
[INFO] Copying artifact[war:au.com.mercury:ReplenishmentR3:0.0.1-SNAPSHOT] to[ReplenishmentR3.war]
[INFO] Copy ear sources to C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.177 s
[INFO] Finished at: 2016-12-24T22:33:03+11:00
[INFO] Final Memory: 12M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.6:ear (default-ear) on project ReplenishmentR4: Deployment descriptor: C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4\META-INF\application.xml does not exist. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Upvotes: 4

Views: 8162

Answers (1)

davidxxx
davidxxx

Reputation: 131346

1) The application.xml file in the EAR is not required any longer since JavaEE 5.0

2) In the maven-ear-plugin configuration, you don't generate the application.xml file :

 <generateApplicationXml>false</generateApplicationXml>

and you specify the location of application.xml here : <applicationXML>src/main/application/META-INF/application.xml</applicationXML>

So, you should be sure that the application.xml file is at this location: src/main/application/META-INF

3) The most simple is not using <generateApplicationXml>false</generateApplicationXml>. It avoids you declaring the application.xml file.

Upvotes: 6

Related Questions