Knock Knock tomcat 302 Moved Temporarily

Knock Knock

So I install my tomcat server, start it up, and when I curl I get 302 Moved Temporary, i move around the internet looking for a solution but I found a lot of technical solutions and install modules that i tried to no success, later I found the solution wasn’t missing modules but a missing “/”, it seems when you enter your url with curl and don’t end it with a “/” it goes to the webapps directory and looks at both the war file and the directory and returns this error. While writing this i also realized that the writing was on the wall, the location in the response is the new “moved to” location

e.g curl -v http://localhost/knock where knock is the URI will fail with 302 temporarily moved but curl -v http://localhost/knock/ will pass, give it a try.

root@testserver lib]# curl -k -v http://localhost:8443/knock
* About to connect() to localhost port 8443 (#0)
* Trying ::1… connected
* Connected to localhost (::1) port 8443 (#0)
> GET /knockHTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/ zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:8443
> Accept: */*
< HTTP/1.1 302 Moved Temporarily
< Server: Apache-Coyote/1.1
< Location: https://localhost:8443/knock/
< Transfer-Encoding: chunked
< Date: Fri, 21 Nov 2014 19:01:35 GMT
* Connection #0 to host localhost left intact


[root@ghasbws00 conf]# curl -k -v https://knock:8443/knock/
* About to connect() to localhost port 8443 (#0)
* Trying… connected
* Connected to localhost ( port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* SSL connection using TLS_DHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
* subject: CN=localhost
* start date: Nov 24 21:32:36 2014 GMT
* expire date: Nov 23 21:32:36 2016 GMT
* common name: localhost
* issuer: CN=cert-trial
> GET /monitor/ HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/ zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:8443
> Accept: */*
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Accept-Ranges: bytes
< ETag: W/”258-1367575008000″
< Last-Modified: Fri, 03 May 2013 09:56:48 GMT
< Content-Type: text/html
< Content-Length: 258

The difference between success and failure is a simple “/” away, hope this helps. This was on RHEL 6.4 running javax.faces.webapp.FacesServlet.service


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s