How to create a Maven web app and deploy to Tomcat - fast


This procedure will help you create a new web application using the m2eclipse Apache Maven plugin for Eclipse, and then deploy and run it on the Tomcat server defined in your Eclipse IDE.


Prerequisites and Assumptions

This document assumes that the following software packages have already been installed and properly configured on your system:


Next, we will use a Maven archetype to generate a new web application project.

In Eclipse, create a new Maven Project. File > New > Other... > Maven Project.

In this first screen shown above, you can typically accept the defaults and click Next >.

Find and select the maven archetype called maven-archetype-webapp, as shown above, and click Next >.

Complete the fields shown above as appropriate to your own project. The Artifact Id is going to be your project's name in Eclipse (and typically the app context in the URL to your web app). Typically, the Group Id and Artifact Id combine to make the base package.

Click Finish.

You should then end up with the following project structure in the Eclipse Package Explorer view:

At this point, you may notice that you cannot add the web app project to the Tomcat server that's in the Eclipse IDE's Servers view when you right-click on the server and select Add and Remove..., so let's fix that.

Right-click on the project in the Eclipse Project Explorer view and select Properties. When the Properties dialog appears, select the Project Facets item.

Click the link to Convert the project to faceted form as shown above.

Check the Dynamic Web Module facet, as shown above.

You'll then see that a yellow info box shows, which says "Further configuration available...". Click that.

Make sure the Content directory is set to src/main/webapp as shown above and click OK. Click any remaining Apply/OK buttons to apply and close out the project Properties dialog.

Now, you should be able to right-click on your Tomcat server in the Servers view of the IDE, choose Add and Remove... and add the project.

You can also verify this by right-clicking on the server and select Start to start it up.

Once started, access http://localhost:8080/yourAppContext in the browser and you should see the Hello World! JSP page that was created in the Maven Web App archetype.

Enterprise Solution Architecture
Cody Burleson is an Enterprise Web Architect, entrepreneur, and writer. He designs and builds solutions with his team at Base22 using IBM WebSphere Portal, IBM Web Content Manager, IBM Connections, and Java/J2EE. He is a tireless student of information technology who loves to invent things, improve things, and share what he learns. You can find more at his blog,