Step 3: Creating a Tomcat Management Service

Jamf Pro Installation and Configuration Guide for Linux 11.23.0

Solution
Application
Content Type
Technical Documentation
Utilities & Services
version
11.23.0
ft:locale
en-US
vrm_version
11.23.0

Requirements

You will need to know the path to the base Java folder (the path without /bin/java at the end) to provide it as the JAVA_HOME environment variable in the management service. The specific path to Java will vary depending on the platform, OS version, Open JDK vs. Oracle JDK, etc.

Following are different methods that you can use to find the path to Java on your system:

  • Reference the JAVA_HOME environment variable:

    $ echo $JAVA_HOME
    /usr/lib/jvm/java-21-openjdk
  • Use alternatives:

    $ alternatives --config java 
    
    There is 1 program that provides 'java'. 
    
      Selection    Command
    ----------------------------------------------- 
    *+ 1           java-21-openjdk.x86_64 (/usr/lib/jvm/java-21-openjdk-
                   21.0.3.0.9-1.el8.x86_64/bin/java) 
    Enter to keep the current selection[+], or type selection number:
  • Use whereis to find "java" and follow the breadcrumbs:

    $ whereis java 
    java: /usr/bin/java
          /usr/share/java 
          /usr/share/man/man1/java.1.gz 
    $ ls -al /usr/bin | grep java$ 
    lrwxrwxrwx 1 root root 22 Jul 18 09:35 java -> /etc/alternatives/java 
    $ ls -al /etc/alternatives | grep java$ 
    lrwxrwxrwx 1 root root 43 Jul 18 09:35 java -> 
    /usr/lib/jvm/java-21-openjdk-21.0.3.0.9-1.el8.x86_64/bin/java
    
  1. Using your preferred text editor, create a Tomcat systemd service file with a command similar to:
    sudo vi /etc/systemd/system/tomcat.service
  2. Paste the following into the tomcat.service file:
    [Unit]
    Description=Jamf Pro Web Application Container
    Wants=network.target
    After=syslog.target network.target
    [Service]
    Type=forking
    Environment=JAVA_HOME=/usr/lib/jvm/java-21-openjdk-21.0.3.0.9-1.el8.x86_64
    Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
    Environment=CATALINA_HOME=/opt/tomcat
    Environment=CATALINA_BASE=/opt/tomcat
    Environment='CATALINA_OPTS=-server -XX:+UseParallelGC'
    Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true'
    ExecStart=/opt/tomcat/bin/startup.sh
    ExecStop=/opt/tomcat/bin/shutdown.sh
    User=tomcat
    Group=tomcat
    UMask=0007
    RestartSec=10
    Restart=always
    [Install]
    WantedBy=multi-user.target
  3. Ensure the JAVA_HOME value in the tomcat.service file matches the path to the JDK installed on the system, not including /bin/java at the end (see above for guidance on finding this path).
  4. Save the tomcat.service file.
  5. Restart the systemd daemon by executing:
    sudo systemctl daemon-reload
  6. Start the Tomcat service by executing:
    sudo systemctl start tomcat
  7. To check the status of Tomcat, execute:
    systemctl status tomcat
  8. Enable auto startup of the Tomcat service at boot by executing:
    sudo systemctl enable tomcat