user4215430
user4215430

Reputation: 27

mvn package error when trying mvn package

I have checked out a project from svn. I am trying to build the project using maven.

It builds fine with mvn compile.

when i try the command mvn package, i get the following error.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.737 s
[INFO] Finished at: 2014-12-22T19:30:54-06:00
[INFO] Final Memory: 12M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war
 (default-war) on project usermanager: Error assembling WAR: webxml attribute is
 required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help
 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE

I find that this is because, the web.xml is not provided to the pom.xml.

I have tried all the ways given in the answers in stack over flow. But none does seem to work

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/maven-v4_0_0.xsd http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.joseph</groupId>
    <artifactId>usermanager</artifactId>
    <packaging>war</packaging>
    <name>User Manager</name>
    <version>1.0</version>
    <description>
        The User Manager is an administration interface for Intranet Users, Groups, Applications, and Permissions.
    </description>
    <url>http://projects.joseph.com/usermanager</url>
    <inceptionYear>2006</inceptionYear>
    <issueManagement>
        <system>Bug Tracker</system>
        <url>http://bugtracker.joseph.com</url>
    </issueManagement>
    <developers>
        <developer>
            <id>lforehand</id>
            <name>Luke Forehand</name>
            <email>[email protected]</email>
            <organization>Joseph Corporation</organization>
            <organizationUrl>http://wiki.josephnet.com</organizationUrl>
            <roles>
                <role>Java Developer</role>
            </roles>
        </developer>
    </developers>
    <build>
        <directory>build</directory>
        <testOutputDirectory>build/test-classes</testOutputDirectory>
        <outputDirectory>build/classes</outputDirectory>
        <sourceDirectory>WEB-INF/src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <resources>
            <resource>
                <directory>deploy</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>deploy</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </testResource>
        </testResources>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jxr-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>changelog-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
    <distributionManagement>
        <site>
            <url>scp://josephnet.com/var/www/projects.joseph.com/usermanager</url>
        </site>
        <repository>
            <id>internal</id>
            <name>Joseph Upload Repository</name>
            <url>file:////snap01/Backup/maven-repo</url>
        </repository>
    </distributionManagement>
    <scm>
        <connection>scm:svn:http://toolbox01/usermanager.josephnet.com/</connection>
        <developerConnection>svn://toolbox01/usermanager.josephnet.com/</developerConnection>
        <url>http://toolbox01/usermanager.josephnet.com/</url>
    </scm>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.joseph</groupId>
            <artifactId>joseph-user-common</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>struts</groupId>
            <artifactId>struts</artifactId>
            <version>1.2.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>1.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.7.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-dao</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

Upvotes: 1

Views: 15908

Answers (3)

user1283183
user1283183

Reputation: 57

I had the same issue and fixed it by modifiying pom.xml

<build>
    <finalName>AngularSpringApp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

You can refer to http://www.javaroots.com/2014/01/webxml-attribute-is-required-error-in.html

Upvotes: 1

kamoor
kamoor

Reputation: 2949

In default this plugin require WEB-INF/web.xml present in build path. If you don'nt have one please set the following property to avoid error

failOnMissingWebXml = false  //case sensitive, default value is true

Example

<project>
...
 <build>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.5</version>  // Must use 2.1-alpha-2+
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>
 </build>
</project>

Creating dummy web.xml file is not a clean way to fix this issue. More configurations are given in apache documentation

Upvotes: 3

LCore
LCore

Reputation: 11

The log has made it very clear

I guess your pom.xml configuration like this:

<packaging>war</packaging>

War packaged in a way must have a WEB-INF/web.xml file, you must add the WEB-INF directory and the web.xml file manually in the webapp directory.

Upvotes: 1

Related Questions