Thursday, August 29, 2013

Problems setting up a dynamic web project in eclipse using Java EE and Tomcat

I created a maven project using the command mvn archetype:generate ... to generate the project structure which I then imported into Eclipse. I then added a dynamic web facet to the project.
You shouldn't have to add any facet, things should just work if your project has a packaging of type war.
It would thus have been nice to provide the full command you used to create your project with the archetype plugin. Did you use the maven-archetype-webapp archetype? Did you ran something like that:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \
  -DgroupId=my.group.id -DartifactId=my-artifact -Dversion=1.0-SNAPSHOT
If not, then be sure that your pom has a war and that you use the default structure for a war project (see Usage for an example).
Then, what plugin are you using for the Eclipse integration? How did you import the project into Eclipse?
If you are using the maven-eclipse-plugin (if you ran eclipse:eclipse), then you need to configure it for WTP support. You need to pass the wtpversion on the command line (or to configure the plugin in the POM):
mvn -Dwtpversion=2.0 eclipse:eclipse
If you are using m2eclipse, then just import your project as a Maven Project (right-click the Package Explorerthen Import... > Maven Projects).
In both case, your project should be recognized as a Dynamic Web Module that you can Run on Server). There is nothing manual to configure for this (no facet to add).
Update: Did you install the Maven Integration for WTP (Optional) when installing m2eclipse?

No comments:

Post a Comment