"Maven" MAVEN deployment Web project Error Webxml attribute is required

Source: Internet
Author: User
Tags stack trace jboss
webxml attribute is required problem

MVN install a Web project, the error is as follows:

[ERROR] Failed to execute goal Org.apache.maven.plugins:maven-war-plugin:2.1.1:war 
(Default-war) on project Com.alpha.webapp:Error assembling WAR: 
webxml attribute is required (or pre-existing web-inf/web.xml if executing in Update mode), [Help 1]
[ERROR] 
[ERROR]-See the full stack trace of the errors, re-run Maven with The-e SW Itch.
[ERROR] Re-run Maven using The-x switch to enable full debug logging.
[ERROR] 
[ERROR] For more information on the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] htt P://cwiki.apache.org/confluence/display/maven/mojoexecutionexception

Reason:

The default webroot for MAVEN Web projects is at Src\main\webapp. If the Web. XML is not found in this directory, the above exception is thrown.

Solve:

Need to add <webResources> configuration in Pom.xml, as follows:

  <build>
	<finalName>simple-webapp</finalName>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactid>maven-war-plugin</artifactid >
			<version>2.1.1</version>
			<configuration>
				<webResources>
					< Resource> <!--This was relative to the Pom.xml directory--and
					<directory>webcontent</ directory>
					</resource>
				</webResources>
			</configuration>
		</plugin >
	</plugins>
  </build>

Or add <webXml> config , as follows:

<build>
	<finalName>simple-webapp</finalName>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactid>maven-war-plugin</artifactid >
			<version>2.1.1</version>
			<configuration>

                            <webxml>webcontent\web-inf\ web.xml</webxml>        

			</configuration>
		</plugin>
	</plugins>
  </build >


<directory>WebContent</directory> is configured as a Web site root directory, such as the directory for this example:


Now MVN install the project to build success:

slf4j:failed to load Class "Org.slf4j.impl.StaticLoggerBinder". Slf4j:defaulting to No-operation (NOP) Logger implementation Slf4j:see http://www.slf4j.org/codes.html#
Staticloggerbinder for further details. [INFO]
Scanning for projects ...                                                                         
[INFO] [INFO]------------------------------------------------------------------------[INFO] Building Com.alpha.webapp 0.0.1-snapshot [INFO]------------------------------------------------------------------------[INFO] [INFO]--- Maven-clean-plugin:2.4.1:clean (Default-clean) @ com.alpha.webapp---[INFO] Deleting D:\Users\axpss\workspace\ Com.alpha.webapp\target [INFO] [INFO]---maven-resources-plugin:2.5:resources (default-resources) @ Com.alpha.webapp ---[Debug] Execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. Buil
D is platform dependent! [INFO] Copying 0 Resource [INFO] [INFO]---MAVEN-COMPILER-PLUGIN:2.3.2:COmpile (default-compile) @ com.alpha.webapp---[WARNING] File encoding have not been set, using platform encoding UTF-8, I
. E. Build is Platform dependent! [INFO] Compiling 1 source file to D:\Users\axpss\workspace\com.alpha.webapp\target\classes [info] [INFO]---
Maven-resources-plugin:2.5:testresources (default-testresources) @ com.alpha.webapp---[Debug] Execute contextualize [WARNING]
Using platform Encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 Resource [INFO] [INFO]---maven-compiler-plugin:2.3.2:testcompile (default-testcompile) @ Com.alpha.webapp-- -[INFO] not compiling test sources [INFO] [INFO]---maven-surefire-plugin:2.10:test (default-test) @ Com.alpha.webapp-
--[INFO] Tests is skipped. 
[INFO] [INFO]---maven-war-plugin:2.1.1:war (default-war) @ com.alpha.webapp---[info] packaging WebApp [INFO] assembling WEBAP p [Com.alpha.webapp] in [D:\Users\axpss\workspace\com.alpha.webapp\target\simple-webapp] [INFO] Processing War project [INFO] Copying webapp webresources [D:\Users\axpss\workspace\com.alpha.webapp\WebContent]  to [D:\Users\axpss\workspace\com.alpha.webapp\target\simple-webapp] [INFO] Copying webapp resources [D:\Users\ Axpss\workspace\com.alpha.webapp\src\main\webapp] [INFO] WebApp assembled in [msecs] [info] Building war:d:\users\ Axpss\workspace\com.alpha.webapp\target\simple-webapp.war [WARNING] warning:selected war files include a web-inf/ Web. XML which'll be ignored (Webxml attribute are missing from war tasks, or Ignorewebxml attribute is specified as ' true ') [INFO] [INFO]---maven-install-plugin:2.3.1:install (default-install) @ com.alpha.webapp---[INFO] installing D:\Use Rs\axpss\workspace\com.alpha.webapp\target\simple-webapp.war to D:\dev\maven-repo\com\alpha\com.alpha.webapp\ 0.0.1-snapshot\com.alpha.webapp-0.0.1-snapshot.war [INFO] Installing D:\Users\axpss\workspace\com.alpha.webapp\ Pom.xml to D:\dev\maven-repo\com\alpha\com.alpha.webapp\0.0.1-SNAPSHOT\cOm.alpha.webapp-0.0.1-snapshot.pom [INFO]---------------------------------------------------------------------- --[INFO] BUILD SUCCESS [INFO]------------------------------------------------------------------------[INFO] Total time:1.078s [INFO] finished At:thu Mar 15:55:56 CST [INFO] Final memory:7m/17m [INFO]-------------------------
 -----------------------------------------------



Deploy the war to JBoss

Locate the Com.alpha.webapp-0.0.1-snapshot.war from the local MAVEN library and copy it to the Jboss/server/*/deploy directory.

If you have already turned on JBoss, because a hot deployment is supported, you will immediately see the following information in the console indicating that the deployment was successful:

Open the Web page to see the effect:


Com.alpha.webapp-0.0.1-snapshot is the name of the war file, and Hello is the <url-pattern> defined in Web. xml






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.