TOMCAT - HTTP Status 404 [duplicate]
Asked Answered
C

3

78

I set up my server in eclipse and when I run it the console prints:

mai 02, 2013 4:05:13 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files (x86)\Microsoft Application Virtualization Client;c:\Program Files (x86)\Open Text\View\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Java\jre7\bin;C:\WorkspacePPL\apache-maven-3.0.4\bin;.
mai 02, 2013 4:05:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ppl-webapp' did not find a matching property.
mai 02, 2013 4:05:13 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
mai 02, 2013 4:05:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 604 ms
mai 02, 2013 4:05:14 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
mai 02, 2013 4:05:14 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
mai 02, 2013 4:05:14 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
mai 02, 2013 4:05:14 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
mai 02, 2013 4:05:14 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/22  config=null
mai 02, 2013 4:05:14 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 493 ms

but then, if I browse http://localhost:8080 I get:

HTTP Status 404 - /
---------------------------------------------------------------------
type Status report
message /
description The requested resource is not available.

While I should see the Tomcat welcome page.

If I run Tomcat outside of eclipse I can reach the welcome page.

Calton answered 2/5, 2013 at 14:29 Comment(4)
Did you try Right click on server, properties , and clicked on Switch Location ?Convenance
WOW! Just did it and I got 5 SEVERE error messages!Calton
What error messages ?Convenance
Check that wether you have your index.jsp/html file under your WebContent folder.Carpentaria
C
238
  1. Click on Window > Show view > Server or right click on the server in "Servers" view, select "Properties".
  2. In the "General" panel, click on the "Switch Location" button.
  3. The "Location: [workspace metadata]" should replace by something else.
  4. Open the Overview screen for the server by double clicking it.
  5. In the Server locations tab , select "Use Tomcat location".
  6. Save the configurations and restart the Server.

You may want to follow the steps above before starting the server. Because server location section goes grayed-unreachable.

server Locations in eclipse view

Convenance answered 2/5, 2013 at 14:35 Comment(9)
What is this "Server Locations" used for? I always add my apps to <tomcat installed folder>/webapps. I want to know more about it.Mesquite
@evan This may help you.Convenance
this didnt work, can you suggest any alternate solutions?Debark
@NiteshVerma What do you get and what steps did you exactly followed after setting up your Tomcat under Eclipse IDE ?Convenance
i followed very common online tutorials to make a web service in java..Debark
One step I suggest to add to answer is regarding removing the deployed projects and cleaning the server so that the server locations option is enabled as it is not enabled by default.Reporter
@NINCOMPOOP - worked like a charm for me! thanks. (my specs : Ubuntu 16.04, Tomcat 8 & Eclipse Neon)Tensive
it works but I am not sure why do we need to do this, can someone explain ?Puga
Where exactly is this "server location" window ?Woolcott
R
28

To get your program to run, please put jsp files under web-content and not under WEB-INF because in Eclipse the files are not accessed there by the server, so try starting the server and browsing to URL:

http://localhost:8080/YourProject/yourfile.jsp

then your problem will be solved.

Religieuse answered 7/5, 2014 at 10:7 Comment(4)
It's not about Eclipse, 'web-inf' is protected under Servlet specs .Convenance
this worked for me. thanks In my case I was just trying to open a normal .jsp fileJacobsen
Nice piece of information. Can you share some link where I can read about things like this.Fantasize
I was (unintentionally) adding index.html file to WEB-INF folder, hence my 3 configured servers, Tomcat7, TomEE+ and JBoss were unable to run that page. All displayed 404. index.html page and all other pages should be under web-content folder, not in WEB-INF folder. Thanks @AgrataLoaves
G
6

You don't have to use Tomcat installation as a server location. It is much easier just to copy the files in the ROOT folder.

Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace. Go to C:\apache-tomcat-7.0.8\webapps, R-click on the ROOT folder and copy it. Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps". You should find something like your-eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or ../tmp1/wtpwebapps if you already had another server registered in Eclipse). Go to the wtpwebapps folder, R-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files). Then reload http://localhost/ to see the Tomcat welcome page.

Source: HTTP Status 404 error in tomcat

Gladstone answered 26/3, 2015 at 7:26 Comment(2)
the above still works in Eclipse Oxygen - I placed docs examples ROOT under wtpwebapps & host-manager manager under webapps directories (inside Eclipse .metadata directory as shown above)Clipper
if you use Struts 2.5 , tomcat version 9.0 works, and no need to Switch Location, use 10.0 will get 404 error.Corkage

© 2022 - 2024 — McMap. All rights reserved.