Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help On A Maven WAR Build Issue

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you updated to the latest version of the WAR plugin?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's looking reasonable to me, give it a go!
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, I haven't used the <configuration> tag before, have you tried commenting that out for now?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, are you providing a web.xml?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, I do exactly the same and it works for me
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow!!! This is something strange!

Would it help if i send you a screen-shot of my directory structure?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not!
 
Avis Sg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Avis Sg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic