Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to build war in maven project

Couple of issues :In for my maven project in Eclipse Run as -- Run on Server is not coming. 2)So i want to run in directly in tomcat server ,wo when i try to create war the following error is coming up .please help me out , i have my web.xml in the specified path only

   Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war)
 on project SchoolMgmtApp: The specified web.xml file 
'F:\WorkSpace\SchoolMgmtApp\src\main\webapp\WEB-INF\web.xml' does not exist -
like image 609
Renukeswar Chinta Avatar asked Feb 18 '12 06:02

Renukeswar Chinta


People also ask

How do I create a war file in Maven?

Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory. This is a normal directory, and all the files inside the WAR file are contained inside the exploded WAR directory.

How to activate a Maven build profile?

Profiles can be activated in the Maven settings, via the <activeProfiles> section. This section takes a list of <activeProfile> elements, each containing a profile-id inside. Profiles listed in the <activeProfiles> tag would be activated by default every time a project use it.


2 Answers

I think the error is self-explaining. You have no web.xml in your project. Is this intended? In theory you can have a WAR file without a web.xml file as Servlet 3.0 supports this kind of deployments. In this case you have to configure the maven-war-plugin like this:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.2</version>
  <configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
  </configuration>
</plugin>
like image 97
chkal Avatar answered Nov 27 '22 22:11

chkal


Your web.xml may not be in a standard location. Some Eclipse project creation wizards put web.xml in WebContent/WEB_INF. In this case you can rearrange the project so that maven likes it, or you can tell maven where to find your web.xml in the pom.xml.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>WebContent\WEB-INF\web.xml</webXml>
    ...
like image 23
Michael Munsey Avatar answered Nov 27 '22 22:11

Michael Munsey