1

I've just installed Tomcat on CentOS 6.3.

# yum install tomcat6
# service tomcat6 start

According to the tutorials I've looked at, I should be able to see a test page now.

# curl -I 127.0.0.1:8080
HTTP/1.1 400 Bad Request
...

# curl -I 127.0.0.1:8080/manager/html
HTTP/1.1 400 Bad Request
...

Why am I getting 400 here? Is there something else that I need to configure?

Dean
  • 143
  • 1
  • 1
  • 6

2 Answers2

5

Tomcat always returns status code 400

Because the webapps directory is empty:

# ls -l /usr/share/tomcat6/webapps/
total 0

https://issues.apache.org/bugzilla/show_bug.cgi?id=50734

Either create a dummy ROOT context to get a 404 status:

# mkdir /usr/share/tomcat6/webapps/ROOT

# ls -l /usr/share/tomcat6/webapps/
total 4
drwxr-xr-x 2 root root 4096 Feb 22 07:47 ROOT

# service tomcat6 restart
Stopping tomcat6:                                          [  OK  ]
Starting tomcat6:                                          [  OK  ]

# curl -I localhost:8080
HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Length: 955
Date: Fri, 22 Feb 2013 06:48:06 GMT

or... install the tomcat6-webapps package to get a 200:

yum info tomcat6-webapps

Name        : tomcat6-webapps
Arch        : noarch
Version     : 6.0.24
Release     : 48.el6_3
Size        : 609 k
Repo        : updates
Summary     : The ROOT and examples web applications for Apache Tomcat
URL         : http://tomcat.apache.org/
License     : ASL 2.0
Description : The ROOT and examples web applications for Apache Tomcat.

tree -L 2 /usr/share/tomcat6/webapps/

/usr/share/tomcat6/webapps/
├── examples
│   ├── index.html
│   ├── jsp
│   ├── servlets
│   └── WEB-INF
├── ROOT
│   ├── asf-logo-wide.gif
│   ├── build.xml
│   ├── favicon.ico
│   ├── index.html
│   ├── index.jsp
│   ├── RELEASE-NOTES.txt
│   ├── tomcat.gif
│   ├── tomcat-power.gif
│   ├── tomcat.svg
│   └── WEB-INF
└── sample
    ├── hello.jsp
    ├── images
    ├── index.html
    ├── META-INF
    └── WEB-INF

10 directories, 12 files

curl -I localhost:8080

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
ETag: W/"7777-1357565143000"
Last-Modified: Mon, 07 Jan 2013 13:25:43 GMT
Content-Type: text/html
Content-Length: 7777
Date: Fri, 22 Feb 2013 06:52:04 GMT
quanta
  • 50,327
  • 19
  • 152
  • 213
2

If you're seeing this error, but you're in an environment where other webapps already exist, you can simply create a ROOT directory, then create a zero byte index.html inside of it. A 200 will be readily returned upon successful curl.

Matthew Ife
  • 22,927
  • 2
  • 54
  • 71