Procedure

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.

About the author

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, codyburleson.com.

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 http://repo1.maven.org/maven2/

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

Anonymous

When I do thad I only get this message:

ERROR BUILD FAILUREINFO ------------------------------------------------------------------------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

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.

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(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fservidor-identidades-webapp&war=
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
... 22 more

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: