I have installed Eclipse and Tomcat 7. The error is that when I run Tomcat from Eclipse it starts, but after that, when I open localhost:8080
in Google Chrome I get HTTP Error 404()
. How can I solve this, please?
This error indicates that the server could not find the desired resource. This resource can be any file such as JSP, HTML, or image resource. Usually, the resource is present, but it is referenced incorrectly. In most cases, you can fix this by correcting the URL.
First, stop your Tomcat, then double click your server, click Server Locations
and check Use Tomcat Installation (takes control of Tomcat installation)
.
It is because there is no default ROOT web application. When you create some web app and deploy it to Tomcat using Eclipse, then you will be able to access it with the URL in the form of
http://localhost:8080/YourWebAppName
where YourWebAppName is some name you give to your web app (the so called application context path).
Quote from Jetty Documentation Wiki (emphasis mine):
The context path is the prefix of a URL path that is used to select the web application to which an incoming request is routed. Typically a URL in a Java servlet server is of the format
http://hostname.com/contextPath/servletPath/pathInfo
, where each of the path elements may be zero or more / separated elements. If there is no context path, the context is referred to as the root context.
If you still want the default app which is accessed with the URL of the form
http://localhost:8080
or if you change the default 8080 port to 80, then just
http://localhost
i.e. without application context path read the following (quote from Tutorial: Installing Tomcat 7 and Using it with Eclipse, emphasis mine):
Copy the ROOT (default) Web app into Eclipse. Eclipse forgets to copy the default apps (ROOT, examples, docs, etc.) when it creates a Tomcat folder inside the Eclipse workspace. Go to C:\apache-tomcat-7.0.34\webapps and copy the ROOT folder. Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps". You should find something like
C:\your-eclipse-workspace-location\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
(or.../tmp1/wtpwebapps
if you already had another server registered in Eclipse). Go to thewtpwebapps
folder and paste ROOT (say "yes" if asked if you want to merge/replace folders/files). Then reloadhttp://localhost/
to see the Tomcat welcome page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With