Ubuntu下OpenJDK7搭配Tomcat8访问localhost:8080空白页求助
Hey there, let's troubleshoot that blank page issue you're seeing with Tomcat 8 and OpenJDK 7 on Ubuntu. I've run into similar problems before, so here are some targeted steps to get to the bottom of it:
- Check Tomcat's service status with:
Look for "active (running)" in the output. If it's stopped, start it withsudo systemctl status tomcat8sudo systemctl start tomcat8. - Verify no other process is hogging port 8080:
If another process is using the port, kill it or adjust Tomcat's port insudo ss -tulpn | grep 8080/etc/tomcat8/server.xml.
Tomcat 8 requires JDK 7 or later, but make sure Tomcat is actually using your OpenJDK 7 installation:
- Check your
JAVA_HOMEvariable:
It should point to your OpenJDK 7 path, likeecho $JAVA_HOME/usr/lib/jvm/java-7-openjdk-amd64. - If
JAVA_HOMEis missing or incorrect, edit/etc/default/tomcat8and set:
Then restart Tomcat withJAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64sudo systemctl restart tomcat8.
Blank pages often hide silent failures. Check these key logs:
- Catalina.out: Tomcat's main log, perfect for catching startup/deployment errors:
Look forsudo tail -n 50 /var/log/tomcat8/catalina.outSEVERElevel messages—these usually flag critical issues like broken dependencies or corrupted web app files. - Localhost log: Checks for errors specific to localhost requests:
sudo tail -n 50 /var/log/tomcat8/localhost.log - Access logs: Confirm your requests are reaching Tomcat:
If you don't see your request entries here, a firewall or network issue might be blocking port 8080.sudo tail -n 20 /var/log/tomcat8/localhost_access_log.*.txt
Tomcat's default page comes from the ROOT web app. If this app is missing or corrupted, you'll get a blank page:
- Check if the ROOT directory exists and has the right files:
You should see files likels -l /var/lib/tomcat8/webapps/ROOT/index.html,index.jsp, and other default assets. If the directory is empty or missing, restore the ROOT app or re-install Tomcat. - Check for successful deployment in
catalina.out—look for a line like:Deployment of web application directory [/var/lib/tomcat8/webapps/ROOT] has finished in [X] ms
Corrupted cache files can break page rendering. Clear them and restart Tomcat:
sudo rm -rf /var/cache/tomcat8/* sudo rm -rf /var/lib/tomcat8/work/* sudo systemctl restart tomcat8
Tomcat runs as the tomcat user by default. If it lacks read access to web apps, it can't serve pages:
- Set correct ownership for the webapps directory:
sudo chown -R tomcat:tomcat /var/lib/tomcat8/webapps/ - Restart Tomcat after adjusting permissions.
If none of these steps resolve the issue, share a snippet of the catalina.out log (focus on any SEVERE errors) and we can dig deeper!
内容的提问来源于stack exchange,提问作者Adrian Apunte

