Skip to end of metadata
Go to start of metadata


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,



  1. Anonymous

    placing the elements <username> and <password> in the <server> section in settings.xml
    doesn't work in my environment. I have to put them in the project's pom.xml.


    Otherwise, I get an Tomcat authenfication failure.
    My environment: Java 1.5.0, Maven 2.2.1, Tomcat 5.5.28


  2. Anonymous

    This topic ASSUMES you have the m2/settings.xml file.

    Where do I get one and what should it contain?

    1. As described by the Maven documentation for settings.xml, your basic settings.xml file looks like this. You can start with this, in fact, even though many of the sections will remain empty...

      <settings xmlns=""

      Now, at minimum, you will want to have access to a public maven repository, so you'll want to add one to the repositories section. The standard public Maven 2 repository is

      The repositories go within the profiles section. Here is the example provided by Maven documentation:

                <name>Codehaus Snapshots</name>
      1. Anonymous

        When I do thad I only get this message:

        INFO ------------------------------------------------------------------------
        INFO A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

        Try downloading the file manually from the project website.

        Then, install it using the command:
        mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=tomcat-maven-plugin -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file

        Alternatively, if you host your own repository you can deploy the file there:
        mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=tomcat-maven-plugin -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=url -DrepositoryId=id


        from the specified remote repositories:
        central (


        from the specified remote repositories:
        central (

        1. Anonymous

          Double check your <plugins> entries. Specifically, your <plugin> for tomcat-mave-plugin should be exactly what is listed above. The only part specific to your project/machine is in the <configuration> section.

      2. Anonymous

        You don't want to recommend that people put <offline/> in their settings.xml file. That will put them in offline mode permanently.

  3. Anonymous

    thank you very much

  4. Anonymous

    Hello guys, I'm getting an exception and I can't make it work, i dunno what i'm doing wrong. Those are my files -->
    My pom.xml is:


    my settings.xml:

    and my tomcat-users.xml:


    <role rolename="manager-gui"/>
    <role rolename="manager"/>
    <role rolename="admin" />
    <user username="admin" password="admin" roles="manager,admin,manager-gui" />

    Hello I am getting the following exception:
    ERROR Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project servidor-identidades-webapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fservidor-identidades-webapp&war= -> Help 1
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project servidor-identidades-webapp: Cannot invoke Tomcat manager
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
    at org.apache.maven.DefaultMaven.doExecute(
    at org.apache.maven.DefaultMaven.execute(
    at org.apache.maven.cli.MavenCli.execute(
    at org.apache.maven.cli.MavenCli.doMain(
    at org.apache.maven.cli.MavenCli.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(
    Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(
    at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    ... 19 more
    Caused by: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fservidor-identidades-webapp&war=
    at org.codehaus.mojo.tomcat.TomcatManager.invoke(
    at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(
    at org.codehaus.mojo.tomcat.TomcatManager.deploy(
    at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(
    at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(
    ... 22 more

    1. Anonymous

      I just ran into the same problem and after two hours of searching was able to solve it.

      If you're using Tomcat 7, you need to modify the deployment url in your pom.xml file. Instead of being <url>http://localhost:8080/manager</url> it should be <url>http://localhost:8080/manager/text</url>

      My guess is that in previous versions of Tomcat the appropriate deployment url was http://server.domain:port/manager/deploy but has now been changed to http://server.domain:port/manager/deploy/text

      Details of how to use the manager for deployment in Tomcat 7 can be found at:

  5. Anonymous

    I am using Tomcat 6.0.32 and I faced an issue (401/403 error) while using the approach mentioned in this article. I fixed my problem by updating my tomcat-users.xml to grant "manager-script" access to the deploying user as shown below:

    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="s3cret" roles="manager-gui, manager-script"/>