M2E and WTP
When you use Maven on a Java web project, it would ideally be nice of course if this played along nicely with Eclipse WTP.
For simple projects, a <packaging>war</packaging> project with some <dependencies> to some normal (<packaging>jar</packaging>) artefacts, this seems to work kind of work nowadays (i.e. m2eclipse 0.10.2, WTP 3.3.3, Eclipse 3.6.1).
For more advanced projects using modularity to aggregate a web application e.g. via Maven WAR overlay, it doesn't seem to work (well/easily/reliably), see e.g. MNGECLIPSE-599 (note http://code.google.com/p/m2eclipse-wtp-ext/, never a good sign if somebody feels the need for something like this), and WTP integration related open issues in m2e.
My article Fully Classpath-based Web Apps in Eclipse based on an embedded Jetty Simple Server may be of interest to you if you have anything but a trivial application. If you aren't ready to give up on WTP and Tomcat yet ;), then read on.
Older blog posts often mention the maven-eclipse-plugin (with <wtpversion>...</wtpversion> or -Dwtpversion=R7) and mvn eclipse:eclipse, or mention the org.eclipse.jst.j2ee.LibCopyBuilder, but either do not seem to be needed anymore today.
So here is how to set it up (for simple projects) :
File / New / Project > Maven > Maven Project
Select org.apache.maven.archetypes:maven-archetype-webapp as Archetype
Add your dependencies to the pom.xml, say e.g. a log4j. (The point adding some JAR is testing whether WTP will see it.)
New Source Folder src/main/java. New Package test, New Class Greeter.
Add a public static String message() { Logger.getLogger(Greeter.class).debug("log"); return "Saluton!"; } to class Greeter
Add <%= Greeter.message() %> to src/main/webapp/index.jsp
Window > Show View > Servers, right-click, New Server ... create a new e.g. Tomcat 6 Server
Project Properties > Project Facets
will initially say "This project is not configured to use project facets."
click "Convert to faceted form"
for Tomcat 6, click on Runtimes tab BEFORE the next step, click on your Server. Note how this changes the Version on Dynamic Web Module from 3.0 to 2.5.
now enable the "Dynamic Web Module"
click "Further configuration available" now shown at the bottom
Set Context root = myapp
Content directory = src/main/webapp.
Uncheck Generate web.xml deployment descriptor (Maven artefact already created one)
Open the .classpath file (e.g. use the Project Explorer and Customize View, uncheck .* resources), to insert an attribute INTO the MAVEN2_CLASSPATH_CONTAINER <classpathentry>, so that it looks like this:
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
Right-click project and Run As > Run on Server
You should see "Hello World!" (from index.jsp) and "Saluton" (from Greeter). Greeter used Log4j, so the JAR was available in Tomcat.
WTP & m2e collaborated, and the JAR files were copied somewhere under your workspace' .metadata\.plugins\org.eclipse.wst.server.core\...\wtpwebapps\mytestwebapp\WEB-INF\lib.
If you are having issues with this set-up, you may would like to check the Project Properties, Web Deployment Assembly settings.
Note that e.g. a Maven > Update Project Configuration will remove the attribute org.eclipse.jst.component.dependency from MAVEN2_CLASSPATH_CONTAINER again (in the current m2eclipse v0.10.2 at least), so careful.
The source code of the example project is attached below, and on https://github.com/vorburger/EclipseWebDevEnv/tree/master/m2e-and-wtp/.