Skip to content

Configure Lightrun with Apache Tomcat

Apache Tomcat is an open-source Java application server that deploys applications using compressed Java web application resource (WAR) files.

To start using Lightrun, add an additional parameter to the JAVA_OPTS configuration variable in the catalina.sh file. This ensures the Lightrun agent runs every time the web server restarts.

  1. Copy the following agent path configuration:

    -agentpath:<install_dir>/agent/lightrun_agent.so=--lightrun_extra_class_path=<tomcat-path>/webapps/<app-name.war>
    
    Replace the placeholders with the appropriate values:

    - install_dir: The path where the agent is saved.

    - tomcat-path: The path to the Tomcat project.

    - app-name.war: The name of the project's WAR file.

  2. Paste the Lightrun agent path as an additional parameter to the JAVA_OPTS variable in your WAR file. For example, if the agent is extracted at /tmp/agent and Tomcat is located in the Downloads folder, use the following configuration:

    JAVA_OPTS="$JAVA_OPTS -agentpath:/tmp/agent/lightrun_agent.so=--alsologtostderr,--lightrun_extra_class_path=/home/someuser/Downloads/apache-tomcat/webapps/app.war"
    
  3. Restart the Tomcat server to apply the configuration.

    ./catalina.sh stop
    ./catalina.sh start
    
  4. An alternative way to launch it is by setting the CATALINA_OPTS variable before starting the server. For example:

    CATALINA_OPTS="-agentpath:<install_dir>/agent/lightrun_agent.so=--alsologtostderr,--lightrun_extra_class_path=<tomcat_path>/webapps/SampleApp-1.0-SNAPSHOT.war" 
    <tomcat_path>/bin/startup.sh
    

Last update: March 27, 2025