In this turorial, we will find out about how to configure Tomcat in eclipse, and how to configure Tomcat to deploy web application.
Table of contents
- Introduction to Tomcat
- Configure Tomcat in Eclipse
- Configure Tomcat server to deploy web application
- Understanding about some configuration files in Tomcat
- Some errors in Eclipse when configure Tomcat
- Wrapping up
Introduction to Tomcat
Tomcat is actually composed of a number of components, including a Tomcat JSP engine and other connectors, but the main component is Catalina, which provides the implementation of the servlet specification. When starting the Tomcat server, it’s Catalina that is actually starting. The variable
CATALINA_HOME is a configuration property that stores the location of the Catalina files.
These are the configuration files in Tomcat’s
Configure Tomcat in Eclipse
The first thing we have to do is to download
Apache Tomcatin a link such as https://tomcat.apache.org/download-90.cgi.
Unzip this file and we have;
This step we will add Tomcat into our Eclipse:
Apply and Closeto agree our Tomcat version.
Configure Tomcat server to deploy web application
After we unzip Tomcat file, we will do something like:
- specify JDK for Tomcat.
binfolder of Tomcat. (With Linux/Ubuntu OS, we have
We will add some code into
# With Windows set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_181" # With Linux/Ubuntu JAVA_HOME="/usr/lib/jvm/open-jdk"
Next, we will configure for account to use Tomcat. Open
Tomcat was defined 4 roles:
manager-gui- allows access to the HTML GUI and the status pages
manager-script- allows access to the text interface and the status pages
manager-jmx- allows access to the JMX proxy and the status pages
manager-status- allows access to the status pages only
We can declare a user with 4 roles
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="tomcat" password="mypassword" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
To run Tomcat, we double click into
startup.shfile if we use Linux/Ubuntu).
On browser, we type
With Tomcat, we have authenticate
passwordthat we write in
In Tomcat, we have
/manager(Tomcat Manager Application) is the most important. It will help us to manage Tomcat, and we can access it with following path:
In order to deploy web application to Tomcat, we can do the following image.
After that, demo application will be deployed to Tomcat.
Run demo application, we have:
Some errors in Eclipse when configure Tomcat
WARNING: Unable to load server configuration from ... server.xml
We only need to copy a path
E:\apache-tomcat-9.0.16\confinto our path where has error.
Getting 404 - Page not found error
We can solve this error that follows some steps:
- Go to Eclipse IDE
- Click on Servers Tab
Double click on Tomcat v9.0 Server at localhost
- New Apache Tomcat configuration page will open
- Go to
Use Tomcat installation(takes control of Tomcat installation)
- Save configuration
RestartServer by right clicking on tomcat server and click
http://localhost:8080again and now you should see working tomcat page