eclipsetomcateclipse-wtp

Do I need to install Tomcat *in addition to* the one provided with Eclipse WTP in order to run in DEBUG from Eclipse?


I am trying to follow the Spring MVC Example from JournalDev.

It builds and runs fine from Eclipse (which includes the WTP plugin):

Jul 30, 2021 2:04:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 30, 2021 2:04:52 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Jul 30, 2021 2:04:52 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Jul 30, 2021 2:04:54 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jul 30, 2021 2:04:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]

But when I try to access it from a browser, I get the following "HTTP Status 404" error:

enter image description here

This tells me that Apache Tomcat is somehow running but something is misconfigured (I get the same error for http://localhost:8080/manager/html)

(running this example webapp on a standalone Tomcat works fine)

What do I need to do to run this webapp (http://localhost:8080/spring-mvc-example/) directly from Eclipse DEBUG perspective?


Solution

  • The short answer is No. No need to install another instance of Tomcat if the Apache Tomcat Maven Plugin is used.

    There is a challenge, however, in setting the context path correctly and deploying the WAR artifact to target/tomcat/web since by default it deploys to target.

    https://www.baeldung.com/tomcat-root-application is a good resource for configuring the context path on a standalone Tomcat installation (i.e. one that is not destroyed and reinstalled upon debug build & run) but for a Tomcat plugin environment the following resource is more helpful: https://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/usage.html