wood burning stoves*
The moose likes Ant, Maven and Other Build Tools and the fly likes Need Help On A Maven WAR Build Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Need Help On A Maven WAR Build Issue" Watch "Need Help On A Maven WAR Build Issue" New topic
Author

Need Help On A Maven WAR Build Issue

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am trying to deploy a create a WAR file for portlet project. I ran the command mvn package but its throwing an exception. I Googled on the exception and i found it to be common one. Here's the exception:



I checked in Google for the exception "[INFO] Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)" and found that it is already logged in JIRA.

http://jira.codehaus.org/browse/MWAR-53?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aworklog-tabpanel#issue-tabs

Is there a workaround for this? Please do let know. I am pretty new to Maven.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you updated to the latest version of the WAR plugin?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I didn't. But now that you mentioned it, I downloaded the 2.1 version jar and the corresponding pom file. But what do i do with them?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

In order to update the plugin you need to reference it in your pom.xml file that is creating the WAR. The plugin will be downloaded and used automatically, see the documentation on the maven-war plugin on their website for details on how to declare this plugin in your POM.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Ok... I looked at the Maven website:
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

So added the declaration mentioned there into my POM file. Now it looks like this:


Is the above one fine? Or do i have to make some other changes as well?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

That's looking reasonable to me, give it a go!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Unfortunately that didn't work also!

Got the same error message. Am i doing something wrong in the.
I created the project in Eclipse by the way.



Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hmm, I haven't used the <configuration> tag before, have you tried commenting that out for now?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
No luck there either!

I just removed the <configuration> </configuration> tag and everything in between. Still it didn't work! If there's any other information that you need please do let me know i'll try to provide it.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

OK, are you providing a web.xml?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I created a "Dynamic Web Project" in Eclipse that comes with a web.xml. It is there in the WEB-INF folder. Then i created the pom file using m2eclipse plugin. Then ran mvn package command. That is the process i am following.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hmm, I do exactly the same and it works for me
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Wow!!! This is something strange!

Would it help if i send you a screen-shot of my directory structure?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Why not!
Avis Sg
Greenhorn

Joined: Aug 29, 2011
Posts: 2
Hi,
The default resource directory for all Maven projects is src/main/resources i.e. it will look for the WEB-INF/web.xml inside this location and as your web structure is not like this hence its throwing this error as its not been able to find the web.xml file. In order to override the location please use the plugin in your pom.xml as following assuming the WEB-INF/web.xml is located inside folder WebContent and pom.xml & folder WebContent are on same directory :-
<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 is relative to the pom.xml directory -->
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
This way you can create your WAR. Cheers!!!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

The default resource directory for all Maven projects is src/main/resources i.e. it will look for the WEB-INF/web.xml inside this location

Actually, in the standard Maven WAR source layout the web.xml source is located at src/main/webapp/WEB-INF/web.xml


JBoss In Action
Avis Sg
Greenhorn

Joined: Aug 29, 2011
Posts: 2
Hi Peter,

Thanks for correcting my typo where i mentioned "resource" instead of "webapp", but what i was trying to explain is how anyone could override the path of web.xml using maven.

Thanks.
 
Consider Paul's rocket mass heater.
 
subject: Need Help On A Maven WAR Build Issue
 
Similar Threads
m2Eclipse + Nexus deploy:deploy problem
Trouble with running Maven Tomcat plugin through Eclipse
maven build error which is strange
maven subversion
problem with mvn deploy