I downloaded Apache Tomcat 6.0.2
And created a new server in Eclipse
- New -> Server
- Select «Tomcat v6.0 Server», Next
- Tomcat Installation Directory -> Where I unzipped Apache Tomcat 6.0.2
- Finish
Then I start the server and go to http://localhost:8080/ to see if it works. And I get a 404 error.
I’ve already googled it and tried to find a solution. But none of those remedies seem to work.
Any thoughts on what the problem is?
Stu Thompson
38.1k19 gold badges107 silver badges156 bronze badges
asked Jul 22, 2009 at 6:57
2
From the top of my head, I thought Eclipse started the tomcat server without anything in it, i.e. no web applications. You have to ‘run’ or actually deploy something in that Eclipse Tomcat server so you won’t get the 404s.
The fact that you do get 404 error messages indicates that Tomcat actually IS running. If you shut it down from Eclipse, you won’t get those 404’s anymore
answered Jul 22, 2009 at 7:10
If your wanting to see your Tomcat Server Homepage then you will need to specify the server path and deploy path. The default is set to Use workspace metadata (does not modify your Tomcat installation).
How to do it.
- Firstly open the Server’s view in Eclipse. (Window >> Show View >> Servers).
- Double click on your Tomcat Server to open the Server Overview.
- Then set the Server Locations to Use Tomcat installation (takes control of Tomcat installation). Save the changes.
- Restart your Server and then go to localhost:8080. This should open the Apache Tomcat Homepage for your server.
Hope this helps!
answered Apr 14, 2012 at 20:46
Shane DoyleShane Doyle
1,0561 gold badge12 silver badges16 bronze badges
The error 404 appears when Tomcat can’t find the localhost.ser file.
In order to get rid of this follow these steps:
1) In Eclipse, right click on server —> Properties —> Click Switch Location —> Apply—>Ok
(This will switch the [workspace metadata] location to the installed Tomcat location.)
2) Then go back to server, double click it. This will open Overview tab. Under this tab goto —>Server Location —> Select Use Tomcat Installation combo box.
Now close it, save it and try run your server and then rerun the URL.
answered May 1, 2012 at 20:20
SonuSonu
511 silver badge1 bronze badge
I agree to drvdijk.
Go to «Servers» window, then select your Tomcat instance. Double.click here you will see the «overview» window. Here you can click on «Open launch configuration» to see your Tomcat arguments («Arguments» tab).
Look for the system property «-Dwtp.deploy». This directory is where your Tomcat is looking for installed web applications, i think you don’t have ROOT.war application here. Isn’t it?
Hope this will help you
answered Jul 22, 2009 at 7:35
sourcerebelssourcerebels
5,1301 gold badge32 silver badges52 bronze badges
answered Jul 24, 2009 at 15:23
The problem is just as drvdijk mentioned, in order to run a webapp on tomcat from eclipse, it needs to be «deployed» to it. This can be done by right clicking the tomcat server -> add and remove
Alternatively, you can try to startup your tomcat server outside of eclipse. Go to your command line and type
$CATALINA_HOMEbinstartup.bat (Windows)
$CATALINA_HOME/bin/startup.sh (Unix)
Where $catalina_home is the directory of where you installed tomcat
answered Jan 8, 2012 at 23:41
kumikodakumikoda
6446 silver badges27 bronze badges
Launch your eclipse Run as administration:
For that right click on eclipse——> run as administration.
It works.
If it not works then again do same and then follow these steps:
In Eclipse, right click on server —> Properties —> Click Switch
Location —> Apply—>Ok
(This will switch the [workspace metadata]
location to the installed Tomcat location.)Then go back to server, double click it. This will open Overview
tab. Under this tab goto —>Server Location —> Select Use Tomcat
Installation combo box.
Now close it, save it and try run your server and then rerun the URL.
Panther
3,2729 gold badges26 silver badges49 bronze badges
answered Dec 16, 2016 at 9:55
1- double click on server
2- Make Sure You have switched correctly the directory for tomcat here
Before
After Fix
3- And Even if you do #2 above you may need do this here as well !
Again here !
answered Dec 19, 2017 at 20:20
shareefshareef
9,00413 gold badges58 silver badges89 bronze badges
Also, notice if you have a duplicated WEB-INF in your path. Sometimes after update a maven project you may have this issue and Tomcat points to an empty folder.
Try to use Tomcat 9 Instead of Tomcat 10
Applications that run on Tomcat 9 and earlier will not run on Tomcat 10 without changes. Java EE based applications designed for Tomcat 9 and earlier may be placed in the $CATALINA_BASE/webapps-javaee directory and Tomcat will automatically convert them to Jakarta EE and copy them to the webapps directory. This conversion is performed using the Apache Tomcat migration tool for Jakarta EE tool which is also available as a separate download for off-line use.
Eric Aya
69.1k35 gold badges179 silver badges250 bronze badges
answered Jul 6, 2022 at 18:04
стасевичстасевич
2282 silver badges9 bronze badges
I downloaded Apache Tomcat 6.0.2
And created a new server in Eclipse
- New -> Server
- Select «Tomcat v6.0 Server», Next
- Tomcat Installation Directory -> Where I unzipped Apache Tomcat 6.0.2
- Finish
Then I start the server and go to http://localhost:8080/ to see if it works. And I get a 404 error.
I’ve already googled it and tried to find a solution. But none of those remedies seem to work.
Any thoughts on what the problem is?
Stu Thompson
38.1k19 gold badges107 silver badges156 bronze badges
asked Jul 22, 2009 at 6:57
2
From the top of my head, I thought Eclipse started the tomcat server without anything in it, i.e. no web applications. You have to ‘run’ or actually deploy something in that Eclipse Tomcat server so you won’t get the 404s.
The fact that you do get 404 error messages indicates that Tomcat actually IS running. If you shut it down from Eclipse, you won’t get those 404’s anymore
answered Jul 22, 2009 at 7:10
If your wanting to see your Tomcat Server Homepage then you will need to specify the server path and deploy path. The default is set to Use workspace metadata (does not modify your Tomcat installation).
How to do it.
- Firstly open the Server’s view in Eclipse. (Window >> Show View >> Servers).
- Double click on your Tomcat Server to open the Server Overview.
- Then set the Server Locations to Use Tomcat installation (takes control of Tomcat installation). Save the changes.
- Restart your Server and then go to localhost:8080. This should open the Apache Tomcat Homepage for your server.
Hope this helps!
answered Apr 14, 2012 at 20:46
Shane DoyleShane Doyle
1,0561 gold badge12 silver badges16 bronze badges
The error 404 appears when Tomcat can’t find the localhost.ser file.
In order to get rid of this follow these steps:
1) In Eclipse, right click on server —> Properties —> Click Switch Location —> Apply—>Ok
(This will switch the [workspace metadata] location to the installed Tomcat location.)
2) Then go back to server, double click it. This will open Overview tab. Under this tab goto —>Server Location —> Select Use Tomcat Installation combo box.
Now close it, save it and try run your server and then rerun the URL.
answered May 1, 2012 at 20:20
SonuSonu
511 silver badge1 bronze badge
I agree to drvdijk.
Go to «Servers» window, then select your Tomcat instance. Double.click here you will see the «overview» window. Here you can click on «Open launch configuration» to see your Tomcat arguments («Arguments» tab).
Look for the system property «-Dwtp.deploy». This directory is where your Tomcat is looking for installed web applications, i think you don’t have ROOT.war application here. Isn’t it?
Hope this will help you
answered Jul 22, 2009 at 7:35
sourcerebelssourcerebels
5,1301 gold badge32 silver badges52 bronze badges
answered Jul 24, 2009 at 15:23
The problem is just as drvdijk mentioned, in order to run a webapp on tomcat from eclipse, it needs to be «deployed» to it. This can be done by right clicking the tomcat server -> add and remove
Alternatively, you can try to startup your tomcat server outside of eclipse. Go to your command line and type
$CATALINA_HOMEbinstartup.bat (Windows)
$CATALINA_HOME/bin/startup.sh (Unix)
Where $catalina_home is the directory of where you installed tomcat
answered Jan 8, 2012 at 23:41
kumikodakumikoda
6446 silver badges27 bronze badges
Launch your eclipse Run as administration:
For that right click on eclipse——> run as administration.
It works.
If it not works then again do same and then follow these steps:
In Eclipse, right click on server —> Properties —> Click Switch
Location —> Apply—>Ok
(This will switch the [workspace metadata]
location to the installed Tomcat location.)Then go back to server, double click it. This will open Overview
tab. Under this tab goto —>Server Location —> Select Use Tomcat
Installation combo box.
Now close it, save it and try run your server and then rerun the URL.
Panther
3,2729 gold badges26 silver badges49 bronze badges
answered Dec 16, 2016 at 9:55
1- double click on server
2- Make Sure You have switched correctly the directory for tomcat here
Before
After Fix
3- And Even if you do #2 above you may need do this here as well !
Again here !
answered Dec 19, 2017 at 20:20
shareefshareef
9,00413 gold badges58 silver badges89 bronze badges
Also, notice if you have a duplicated WEB-INF in your path. Sometimes after update a maven project you may have this issue and Tomcat points to an empty folder.
Try to use Tomcat 9 Instead of Tomcat 10
Applications that run on Tomcat 9 and earlier will not run on Tomcat 10 without changes. Java EE based applications designed for Tomcat 9 and earlier may be placed in the $CATALINA_BASE/webapps-javaee directory and Tomcat will automatically convert them to Jakarta EE and copy them to the webapps directory. This conversion is performed using the Apache Tomcat migration tool for Jakarta EE tool which is also available as a separate download for off-line use.
Eric Aya
69.1k35 gold badges179 silver badges250 bronze badges
answered Jul 6, 2022 at 18:04
стасевичстасевич
2282 silver badges9 bronze badges
- HowTo
- Java Howtos
- Tomcat 404 Error
- Tomcat 404 Error in Java
- Tomcat 404 Error in Eclipse
This tutorial demonstrates how to troubleshoot the Tomcat 404 error in Java.
Tomcat 404 Error in Java
While using the apache Tomcat server for web development in Java, the most common error is the HTTP Status 404
. This error means the server cannot find the required resource.
The required file can be anything like HTML, Image Resource or JSP.
Most of the time, the error occurs when the required reference is not present or is referenced incorrectly. The error looks like this:
There are three main reasons for this error in Apache Tomcat.
-
The URL is Case Sensitive
The Tomcat URLs are case sensitive, so whenever you are trying to write the URL by yourself, make sure that it is also correct in its case. Otherwise, it will throw the 404 status error.
-
The Servlets Do Not Handle the URL
The
@Webservlet()
is also used to handle theURL/demo
, but when requesting the URL, it can beURL/this_demo
, which is a different reference. This can be fixed by using the URL mapping and referencing the URL correctly.See example:
@WebServlet("/demo") public class Demo extends HttpServlet { // Your code here. }
Now, if the website requests the URL
this_demo
, we can solve it by changing the demo tothis_demo
in the URL mapping. -
Resource Forward by Servlets Does Not Exist
When the resource forwarded by servlets does not exist, the Tomcat will throw a 404 error. Make sure the resource forwarded exists and the name of that resource is correct.
For example, if we are referencing the
DemoForm.jsp
but the real name of that resource isDemo_Form.jsp
, it will throw the 404 status error. We can change theDemoForm.jsp
toDemo_Form.jsp
to solve this error.See example:
String Demo_Form= "frontend/Demo_Form.jsp"; RequestDispatcher Request_Dispatcher = request.getRequestDispatcher(Demo_Form); Request_Dispatcher.forward(request, response);
Tomcat 404 Error in Eclipse
While working with Tomcat in Eclipse IDE, the same 404 error can occur even if we have managed all the solutions above. Sometimes, even if the Tomcat starts, the browser will throw the 404 error while working with Eclipse IDE.
This error is because Tomcat is not configured correctly in the Eclipse IDE. To solve this issue in Eclipse, follow the steps below.
-
Make sure Tomcat is downloaded and extracted.
-
Open the Eclipse IDE. Make sure you are using the EE version of Eclipse.
-
Go to the
Servers
tab in Eclipse, and if you see no Tomcat server, clickcreate a new server
. Or go to theWindow
menu, thenPreferences
and thenServer
andAdd New
. -
Select your version of Tomcat from the Apache folder on the page and click
Next
. -
Click
Browse
and select your Tomcat directory. The installed JRE is okay if it works; otherwise, add the latest version. ClickNext
. -
Select your project and click
Add
and thenFinish
. A Tomcat server will be added to theServers
tab. -
Double click the Tomcat Server in the
Servers
tab, and a page will open. Under theServer Locations
, selectUse Tomcat Installation
. -
Save the configuration by Ctrl+S.
-
Restart the server, right-click on the server name in the
Servers
tab and clickRestart
. -
Now the server works perfectly.
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn
Facebook
Related Article — Java Error
- Details
- Written by
- Last Updated on 05 November 2019 | Print Email
In Java web development with Tomcat, it’s very often that you get HTTP 404 error like this:
The error code is HTTP 404 (not found) and the description is:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
This error means the server could not find the requested resource (JSP, HTML, images…) and returns HTTP status code 404. Most of the time, you can fix this error by correcting the URL. However, sometimes it’s not easy like that, making it is an annoying error.
Here I suggest some possible reasons and how to fix the error HTTP 404 in Java web development with Tomcat.
1. The URL is not handled by any Java servlets
You need to check URL mapping in your servlet classes to make sure the requested URL is actually handled by a servlet. For example:
@WebServlet("/view_book") public class ViewBookServlet extends HttpServlet { ... }
This servlet handles the URL /view_book. If the request URL is /view_books the server will raise HTTP 404 error. You can fix by either correcting the URL or correcting the URL mapping in the @WebServlet annotation.
In older Java web application, you have to check the web deployment descriptor file web.xml because a Java servlet can be mapped to URL via XML like this:
<servlet-mapping> <servlet-name>ViewBookServlet</servlet-name> <url-pattern>/view_book</url-pattern> </servlet-mapping>
2. Java servlet forwarding to a resource that does not exist
In this case, the requested URL is handled by a Java servlet, but code in the servlet forwards to a resource (JSP, HTML…) which does not exist, as shown in the following screenshot:
The code in the servlet class would look like this:
String registerForm = "frontend/registerform.jsp"; RequestDispatcher dispatcher = request.getRequestDispatcher(registerForm); dispatcher.forward(request, response);
You can fix by correcting the forward path in the servlet, and make sure that the forwarded resource does actually exist in the given path.
3. URL is case-sensitive
Note that Tomcat treats URL as case-sensitive, for instance /Register is different than /register. So you need to check and use correct case for the letters in request URL.
Also pay attention to the webapp name in the URL, for instance http://localhost:8080/BookstoreWebsite/ is different than http://localhost:8080/BookStoreWebsite/
TIP: in Eclipse, you can right click on the project, then click Run As > Run on Server, the IDE will always use the correct name of the web application.
Finally, you should not let the user see the raw HTTP 404 error page rendered by the server. Instead, you should design your own user-friendly 404 error page – follow this tutorial: How to Handle Error for Java web applications.
You can also watch the video version below:
Other Java Servlet Tutorials:
- Java Servlet Quick Start for beginners (XML)
- Java Servlet for beginners (annotations)
- Java Servlet and JSP Hello World Tutorial with Eclipse, Maven and Apache Tomcat
- Handling HTML form data with Java Servlet
- Java File Download Servlet Example
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.
Add comment
Today I was running Apache Tomcat from Eclipse and while accessing URL http://localhost:8080
found HTTP Status 404 – Not Found
error.
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Do you have any of below questions?
- Tomcat starts but doesn’t display webpage
- Can’t connect to Tomcat even though it’s running
- How to Solve Common Tomcat Problems
- Can’t connect to localhost via browser. Can ping localhost
- How to open tomcat home page in browser
- localhost 8080 not working for tomcat
For all above types of issues, you are at right place.
I’ve setup Apache Tomcat by following detailed steps using in-depth tutorial.
Steps worked perfectly fine but as I didn’t have any projects added to tomcat webapps folder
it threw 404 error for me.
If you also face 404 Page not found error
then try following below steps:
Step-1
- Go to Eclipse IDE
- Click on
Servers
Tab - Double click on
Tomcat v9.0 Server at localhost
Step-2
- New Apache Tomcat configuration page will open
- Go to
Server Location
section - Select
Use Tomcat installation
(takes control of Tomcat installation)
Step-3
- Save configuration
Restart
Server by right clicking on tomcat server and clickRestart
- Visit
http://localhost:8080
again and now you should see working tomcat page
I hope this tutorial works well for you. Happy coding and keep visiting.
This tutorial works for Apache
Tomcat 10.0
too.
Join the Discussion
If you liked this article, then please share it on social media. Still have any questions about an article, leave us a comment.
Share:
I’m an Engineer by profession, Blogger by passion & Founder of Crunchify, LLC, the largest free blogging & technical resource site for beginners. Love SEO, SaaS, #webperf, WordPress, Java. With over 16 millions+ pageviews/month, Crunchify has changed the life of over thousands of individual around the globe teaching Java & Web Tech for FREE.
Reader Interactions
Problem
After restarting the Tomcat Application server the HTTP Status 404 error occurs in IBM Rational Project Conductor.
Symptom
Apache Tomcat — Error report
HTTP Status 404 — Servlet equinoxbridgeservlet is not available
type Status report
message Servlet equinoxbridgeservlet is not available
description The requested resource (Servlet equinoxbridgeservlet is not available) is not available
Cause
The {$JazzInstallDir}Tomcatwebappsjazz directory may be corrupted.
Resolving The Problem
Clean out the {$JazzInstallDir}Tomcatwebappsjazz Directory:
- Make sure that the right jazz.war file is present in the {$JazzInstallDir}Tomcatwebapps directory
- Stop the Tomcat application server
- Rename the jazz folder found in {$JazzInstallDir}Tomcatwebapps to jazz_old
- Move the jazz_old folder to a location, for backup purposes
- Restart the Tomcat application server
At this point the Tomcat application server should re-deploy the jazz.war file. This will create a new jazz Directory.
If the problem persists, check available room on the drive on which the Tomcat server is installed. It might be a disk space issue.
[{«Product»:{«code»:»SSN2WR»,»label»:»Rational Project Conductor»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud & Data Platform»},»Component»:»Team Server»,»Platform»:[{«code»:»PF033″,»label»:»Windows»}],»Version»:»1.0.0.1″,»Edition»:»»,»Line of Business»:{«code»:»LOB45″,»label»:»Automation»}}]