---
title: "Spring PetClinic as a Stand-alone App"
slug: "spring-petclinic-as-a-stand-alone-app"
updated: 2023-12-07T07:37:17Z
published: 2023-12-07T07:37:17Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Spring PetClinic as a Stand-alone App

This guide describes how to enable the Retrace Java profiler on a stand-alone Spring PetClinic application.

The app has the following pages:

1. Home - a simple landing page
2. Find Owners - page showcasing simple DB queries as part of sub-transactions that add a new owner and find records.
3. Veterinarians - page that shows the list of vets in tabular format
4. Error - used to simulate an exception. The exception will be auto-captured by the profiler and then reported to your Retrace account.

          Note

          

More information about the PetClinic app can be found at [https://spring-petclinic.github.io/](https://spring-petclinic.github.io/).

## Pre-requisites

1. Retrace agent. Your machine will appear on your Retrace account after installing the agent.
  1. Windows: [https://docs.stackify.com/docs/net-agent-installation-overview](https://docs.stackify.com/docs/net-agent-installation-overview)
  2. Linux: [https://docs.stackify.com/docs/linux-installation](https://docs.stackify.com/docs/linux-installation)
2. Java (*either JRE or JDK will work*)
  1. Download the appropriate package for your environment at [https://jdk.java.net/21/](https://jdk.java.net/21/)
  2. Extract the contents of archive and take note of the path.
    - On Windows:  

![javaPath.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/javaPath.png)
  3. Add the system variables: `JAVA_HOME=/Path/To/Your/JavaDir` and `Path=${existing path values};/Path/To/Your/JavaDir/bin`
    - On Windows:  

![envVars.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/envVars.png)
          Note

          

The app used in this guide does not require the JRE_HOME variable so the variable seen in the screenshot can be disregarded. Other apps, however, might require this variable.
    - On Linux:

```
$ export JAVA_HOME=/Path/To/Your/JavaDir
$ export PATH=${PATH}:/Path/To/You/JavaDir
```
  4. Test by opening the terminal and executing the command `java -version`. ![javaVersion.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/javaVersion.png)

Now that both the Retrace agent and Java are installed, let's proceed to the next section.

## Enabling APM on the Java App

1. Download the sample app from the GitHub repo and save to your preferred location: [https://github.com/stackify/example-apps/raw/main/sample-java-petclinic/spring-petclinic-2.7.0.jar](https://github.com/stackify/example-apps/raw/main/sample-java-petclinic/spring-petclinic-2.7.0.jar). Clicking on the click will trigger the download of a jar file.
2. Open the terminal and go to the same directory you saved the app (jar file) in Step 1, and then run the app using the Java command:

```
C:\your-app-path> java -Djava.io.tmpdir="C:\your-app-path\" -Dserver.port=<any-unused-port> -javaagent:"C:\ProgramData\Stackify\Profiler\Java\stackify-java-apm.jar" -DSTACKIFY_APPLICATION_NAME="Your-App-Name" -DSTACKIFY_ENVIRONMENT_NAME="Your-Env-Name" -jar spring-petclinic-2.7.0.jar
```

Image showing the app's path/location: ![appPath_win.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/appPath_win%281%29.png)

Image showing a successful launch of the app: ![appStarted.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/appStarted.png)

```
$ java -Dserver.port=<any-unused-port> -javaagent:/usr/local/stackify/stackify-java-apm/stackify-java-apm.jar -DSTACKIFY_APPLICATION_NAME="Your-App-Name" -DSTACKIFY_ENVIRONMENT_NAME="Your-Env-Name" -jar spring-petclinic-2.7.0.jar
```

Image showing the app location on Linux: ![appPath_linux.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/appPath_linux.png)

Image showing a successful start of the app on Linux: ![appStarted_linux.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/appStarted_linux.png)
  1. On Windows
  1. On Linux:

          Note

          

To check port availability, open your browser and go to http://localhost:<*port-number*>, e.g. http://localhost:80. If a web page loads (*i.e. no errors such as "localhost refused to connect/the site can't be reached"*), then the port is already in use and you may need to choose a different port.

1. Send requests to the app and view APM data in Retrace. To view the app, open your browser and go to http://localhost:[*port-used-in-step-2*].

Here's what the landing page looks like: ![appLandingPage.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/appLandingPage.png)

And how APM will appear in Retrace: ![apmDashboard.png](https://cdn.document360.io/3fcaf473-a1ef-4778-aa2c-fd28411c2b01/Images/Documentation/apmDashboard.png)

## Post-Installation Checks

1. The Retrace Java profiler will generate output logs at `C:\ProgramData\Stackify\Java\`, in `.\debug` for debug logs and `.\log` for trace logs after the app receives any request. In Linux, the paths are at `/usr/local/stackify/stackify-java-apm/debug` and `/usr/local/stackify/stackify-java-apm/log`

As long as traces are generated, it should only be a matter of time before the app appears in your Retrace account.

## Done!

To learn more about viewing your application's data, be sure to check out [documentation on the App Dashboard](/v1/docs/account-application-dashboard-overview).
