Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Create Java Heap Dumps for Tomcat

Welcome to this hands-on lab, where we will obtain a heap dump of a running Tomcat instance, and also enable the start-up option to create a heap dump on an _Out of memory_ error. We are using Apache's Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The server provided in this lab environment is running Red Hat Enterprise 8 and has Tomcat 9 pre-installed for you, available on port **8080**. You will log into the server and perform the associated tasks.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon May 08, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Test to Ensure You Can Access the Preconfigured Tomcat Instances on Port 8080

    Visit the Tomcat server's public IP address on port 8080. Connect to the Tomcat GUI and log in. The username and password to use are the same as what's provided for CLI access.

    To access the server, copy the external IP address and test in your browser by using this IP address and appending the :8080 to it.

    For example, if the server's IP address is 3.92.152.3, then you would put the following into your web browser:

    http://3.92.152.3:8080

    You should see the Tomcat GUI.

    Note: It may take from 3 to 10 mins after the hands-on lab has started before you can access the Tomcat server.

  2. Challenge

    Set the Option for a Heap Dump on Out of Memory Error

    You will need to set a startup option for Tomcat so that it creates a heap dump on an Out of memory error.

    The file that is automatically created should go to /usr/local/tomcat9, and should be called heapcheck.hprof.

    These are the options to add to the Tomcat startup file (you may need to create the file):

    1. -XX:+HeapDumpOnOutOfMemoryError
    2. -XX:HeapDumpPath=PATH-AND-NAME-OF-FILE

    These should be set in a file called setenv.sh, in the bin folder, and they should be exported as CATALINA_OPTS.

  3. Challenge

    Create a Manual Heap Dump and Call It heapcheck.hprof

    Use the appropriate command to create a heap dump from live memory, and call it heapcheck.prof.

    Use the following options for the heap dump:

    • Only live objects
    • Binary format
    • File = heapcheck.hprof

    You will need to be in the correct folder to be able to perform this successfully.

    If you get an error, you are not in the correct location to perform the task.

  4. Challenge

    Transfer the heapcheck.hprof File from the Tomcat Server to Your Local Computer

    You will need to do the tasks required to get the /usr/local/tomcat9/heapcheck.hprof file from the Tomcat folder to your own local computer.

    This may require copying or moving the file and changing its ownership or permissions.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans