Hello everyone! I've been struggling with MAVEN for a long time now and I don't know what to do anymore, so I am writing here is desperate need of help. Here is the actual problem: I am creating a java web services ( SOAP) using CXF and eclipse. I know have a dynamic web project that runs on Tomcat 7 and I want to export my web project using Maven into WAR format. I've read so many tutorial and sites, but i still can't manage to create a war package. So, please, someone help me with writing with the pom.xml file. Here is the structure of my Dynamic Webprojet :
I've managed to write some pom.xml files but all of them gave me errors. Can you, please, help me with creating the pom.xml that should generate the war file, so I can deploy it on Tomcat 7. I will be monitoring this thread so I can answer without delay.
Maven uses "convention over configuration" and expects your web project to be set up in a certain way. And what you have isn't the way. It's possible - but difficult - to use a different directory structure and Maven doesn't recommend it without a really good reason.
This page show you the "Maven way" directory structure.
Thank you for the answer, Jeanne . I tried again but no success...
Allright, i tried again ... I've got the following structure:
I try mvn compile war:war and the following error pops out: Failed to execute goal org.apache.maven.plugis:maven-war-plugin:2.1.1 war. Error assembling WAR: webxml attribute is required ... I dont know whether is should install this plugin or it downloads itself automatically. Also ... I have webxml .. ? Can someone explain ?
author & internet detective
Your directory structure is better, but still not what maven is expecting. It wants web.xml in main/resources/webapp/WEB-INF/web.xml. You left out the webapp folder along the path.
The error means the web.xml isn't where Maven expects it to be so when you fix that, you should be good.
Joined: Jul 03, 2013
Hi there, sorry for my delay but I was offline for two days... I tried again with this structure:
The pom.xml file looks like:
I still cant manage to make it generate war file. It gives me the following error ... Failed to execute maven.plugins:maven-war-plugin:2.1.1:war. Error assembling WAR: webxml attribute is required... I have the webxml file. What attribute does it require ?
author & internet detective
Well, I still can't manage to generate a war file. It generates me 800kb WAR file. I want later to upload this WAR file to a Tomcat server and use my web services from there ... but I just cant do it. Can someone explain me what should I do, please. If you have any questions you may ask me, too. I am trying with Maven Project on Eclipse and with Dynamic Web Project, too.
Well, I thought that it should be the same WAR file that eclipse exports( it is about 10 MB). Thanks for the support. Tomorrow I will try these plugins and I hope it would work this time. I suppose that I don't need to install anything just to configure the pom file and maven will take care of the rest by itself. Thank you a lot for all the explanations
Have you examined the contents of the WAR file to see what JARs Eclipse provided as compared to what Maven provided? Or to see what the other differences are? If Maven successfully compiled your code then it will have included all JARs listed in your dependencies and all of their dependencies; perhaps you Eclipse project listed more JARs that was needed in the Build Path.