Bootstrap FreeKB - Tomcat - Resolve 404 Not Found
Tomcat - Resolve 404 Not Found

Updated:   |  Tomcat articles

Let's say you have deployed a WAR to your Tomcat application server and when requesting the WAR, you are getting 404 Not Found. Check out my article on deploying a WAR to Tomcat.

Let's say you have deployed helloworld.war to the webapps folder. The first thing you'll want to do is to see if the WAR has been unpacked. In this scenario, the helloworld.war should be unpacked into the helloworld directory.

~]# ls -l /opt/tomcat/webapps/
drwxr-x---. 4 root root   51 Jul 4  10:14 helloworld
-rwxr--r--. 4 root root 2122 Jul 4  10:14 helloworld.war

 

And there should be an index page in the unpacked directory such as index.jsp or index.html.

~]# ls -l /opt/tomcat/webapps/helloworld
drwxr-x---. 4 root root   51 Jul 4  10:14 META-INF
drwxr-x---. 4 root root   51 Jul 4  10:14 WEB-INF
-rw-r--r--. 4 root root 2122 Jul 4  10:14 index.jsp

 

By default, Tomcat listens on port 8080 for HTTP connections and port 8443 for HTTPS connections. You can double check this in the <tomcat base directory>/conf/server.xml file.

<Connector port="8080"
           protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"/>

 

When Tomcat is started, the <base tomcat directory>/logs/catalina.out log will display Tomcat's listening ports.

~]# cat $CATALINA_HOME/logs/catalina.out
17-Sep-2022 17:45:17.371 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
17-Sep-2022 17:45:17.641 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]
17-Sep-2022 17:45:17.761 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]

 

In this scenario, you should now be able to get the default helloworld welcome page at:

  • http://localhost:<http port>/helloworld
  • http://<tomcat IP address>:<http port>/helloworld
  • http://<tomcat server hostname>:<http port>/helloworld

 

Or you could use the curl command.

C:\>curl http://localhost:8080/helloworld/ -v
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /helloworld/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200
< Accept-Ranges: bytes
< ETag: W/"142-1668133197822"
< Last-Modified: Fri, 11 Nov 2022 02:19:57 GMT
< Content-Type: text/html
< Content-Length: 142
< Date: Mon, 14 Nov 2022 08:12:47 GMT
<
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello World
</body>
</html>* Connection #0 to host localhost left intact

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 27c55c in the box below so that we can be sure you are a human.