user614454
user614454

Reputation: 123

Tomcat 404 Not Found error

My web application runs fine with Eclipse & Tomcat on my desktop PC. When I uploaded the war file to the actual server, I wasn't able to access all the servlets with the following error message. Other JSP and HTML files had no problems.

The requested URL /HelloWorld/TryingServlet was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

How is this caused and how can I solve this?

Upvotes: 2

Views: 8090

Answers (2)

cherouvim
cherouvim

Reputation: 31928

Your problem is that in your production environment tomcat is being fronted by an apache httpd which does not forward requests to tomcat for urls of the form /foobar (without an extension). Apache doesn't know how to deal with those URLs and tries to serve them as static files from the disk. The files are not there so it tries to execute the 404 rule which is badly configured (the configured 404 file is itself missing as well - but that's another problem).

Solutions:

  • Assign an extension to all your servlets and specify that to apache. E.g .do (like struts does) so your servlet becomes /foobar.do. You'll then need to ask your sysadmin to specify that *.do goes to tomcat.
  • Ask your sysadmin to configure apache to send all requests to tomcat apart of those for static files. E.g *.jpg, *.png, *.css, *.js etc

Upvotes: 1

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181460

Try this url:

http://YOUR_IP:8080/HelloWorld.war/TryingServlet

Replace HelloWorld.war with the actual name of your war file...

Upvotes: 1

Related Questions