Porting a Dynamic Web Application from Eclipse to Apache-Tomcat for manual running

StackOverflow https://stackoverflow.com/questions/23507602

  •  16-07-2023
  •  | 
  •  

Вопрос

I have a web app stored in an Eclipse Workspace. Say for example its root directory is

hello-world-web

It works perfectly in the Eclipse IDE using Apache Tomcat. However, when I transfer it to Tomcat's document root and access it with catalina running, it doesn't work. It gives a not found error.

Is there any work around on this?

Это было полезно?

Решение

In Java. web applications are usually deployed as WAR files (or extracted directories in the exact same format as a WAR file). A WAR file is a regular ZIP file (like a JAR) that contains some extra structure and files, in particular a /META-INF/web.xml file that describes the components of your web application.

Eclipse is smart and allows you to cheat by running web applications without any special packaging or deployment, straight from the IDE.

Your best bet is to learn a tool like Maven, Ant or Gradle, and have it create a WAR file out of your project. Eclipse also has an option to export a WAR File directly. Once that's done, copy the WAR file to Apache Tomcat's webapps directory, where it will be available under the path /foo for a WAR named foo.war. To serve as the root application (/), name the WAR ROOT.war. When you start Apache Tomcat (or if it's running, when you copy the WAR file) you should see a message on the console/log informing you that the application has been deployed.

For more information on creating WAR files, see the Stack Overflow question "How to create war files"

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top