You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu16.04下Tomcat8启动失败:tomcat.service状态码203求助

Fixing Tomcat 8 Startup Failure (Exit Status 203) on Ubuntu 16.04

Hey there, that exit code 203 for Tomcat usually points to two common culprits: incorrect Java 8 environment configuration or permission issues with Tomcat's files and directories. Let's work through this step by step to get your server up and running.

Step 1: Verify Java 8 Installation & Environment Variables

Tomcat 8 relies on Java 8, so first make sure it's properly set up:

  • Check if Java 8 is installed:
    java -version
    
    You should see output like openjdk version "1.8.0_XXX" or Oracle Java 8. If not, install OpenJDK 8 with:
    sudo apt-get update && sudo apt-get install openjdk-8-jdk
    
  • Set the JAVA_HOME environment variable:
    Edit the system environment file:
    sudo nano /etc/environment
    
    Add this line (adjust the path if you installed Oracle Java instead):
    JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
    
    Save and exit, then apply the changes:
    source /etc/environment
    
    Verify it's set correctly:
    echo $JAVA_HOME
    

Step 2: Fix Tomcat Permissions

This is one of the most common causes for exit status 203. The fix depends on how you installed Tomcat:

If you installed Tomcat via apt:

  • Check the user Tomcat is supposed to run as:
    cat /etc/default/tomcat8
    
    Look for TOMCAT_USER=tomcat8 (this is the default).
  • Ensure Tomcat's core directories are owned by the tomcat8 user:
    sudo chown -R tomcat8:tomcat8 /var/lib/tomcat8 /var/log/tomcat8 /var/cache/tomcat8
    

If you manually downloaded and extracted Tomcat:

  • First create a dedicated tomcat8 user (best practice for security):
    sudo useradd -r -m -U -d /opt/tomcat8 -s /bin/false tomcat8
    
  • Transfer ownership of the Tomcat directory to this user:
    sudo chown -R tomcat8:tomcat8 /opt/tomcat8
    
  • Make sure the startup/shutdown scripts are executable:
    sudo chmod +x /opt/tomcat8/bin/*.sh
    

Step 3: Check Detailed Logs for Exact Errors

If the above steps don't fix it, dig into the logs to find the root cause:

  • For apt-installed Tomcat, check the Catalina log:
    sudo tail -n 50 /var/log/tomcat8/catalina.out
    
  • For manually installed Tomcat, logs are in your Tomcat directory:
    sudo tail -n 50 /opt/tomcat8/logs/catalina.out
    
  • You can also check systemd's detailed service logs:
    sudo journalctl -u tomcat8.service -xe
    
    This will show specific issues like "Java not found" or "permission denied when reading server.xml".

Step 4: Fix Systemd Service File (Manual Installations)

If you set up Tomcat manually, your systemd service file might have incorrect paths or user settings. Create/edit the service file:

sudo nano /etc/systemd/system/tomcat8.service

Paste this configuration (adjust paths to match your Tomcat and Java installation):

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat8/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat8
Environment=CATALINA_BASE=/opt/tomcat8
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat8/bin/startup.sh
ExecStop=/opt/tomcat8/bin/shutdown.sh

User=tomcat8
Group=tomcat8
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

Save and exit, then reload systemd and restart Tomcat:

sudo systemctl daemon-reload
sudo systemctl start tomcat8

Verify the Fix

Check if Tomcat is running:

sudo systemctl status tomcat8

You should see active (running) in green. You can also test by visiting http://localhost:8080 in your browser—you'll see the default Tomcat welcome page if everything works.

内容的提问来源于stack exchange,提问作者shareef

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:48:30