Java APM
Get AI insights and automated debugging experience for your Java applications by using the Middleware Java Agent (version '1.7.0' or higher).
🚀 Key Features
- Capture exception and error details automatically
- Framework agnostic
- Exception method recording for all files
- Library file detection for more focussed error tracking
🛠️ APM Setup
Download the Middleware Java Agent To download Middleware Java Agent with OpsAI support download it from our Github Release Page (version '1.7.0' or higher)
Run your java project with the Agent Add the
-javaagent
flag before the-jar
parameter when running your Java application, specifying the full path to the Middleware agent JAR file.
Eg:
MW_API_KEY=<MW_API_KEY> \ java -javaagent:<PATH-OF-MIDDLEWARE-JAVA-AGENT-JAR> \ -Dotel.service.name=<YOUR-SERVICE-NAME> \ -jar <YOUR-APP-JAR-FILE>.jar
⚡ Exception Code Capturing
The SDK automatically captures:
- Exception types and messages
- Stack traces with line numbers
- Function names and bodies
- File paths and line ranges
- Library file detection (for files in
~/.m2/repository/
,~/.gradle/caches/
,lib/
,libs/
, JAR files in classpath, and External JARs, Maven/Gradle dependencies )
Automatic Detection
The SDK will automatically detect:
- Git commit SHA
- Repository URL from your project's .git directory. No additional configuration is needed if your project is a git repository.
Manual Configuration
If you need to override the automatic detection or if your project is not a git repository, you can set these environment variables:
MW_VCS_COMMIT_SHA=$(git rev-parse HEAD) MW_VCS_REPOSITORY_URL=$(git config --get remote.origin.url)
This lets Middleware know exactly which version of your code is running, so it can suggest the right fix and even create a solution PR for you.
Turning Off OpsAI:
The OpsAI support for Java APM is enabled by default. To opt out you can set the environment variable MW_OPSAI_SUPPORT=false
Eg.
MW_OPSAI_SUPPORT=false \ # Here MW_API_KEY=<MW_API_KEY> \ java -javaagent:<PATH-OF-MIDDLEWARE-JAVA-AGENT-JAR> \ -Dotel.service.name=<YOUR-SERVICE-NAME> \ -jar <YOUR-APP-JAR-FILE>.jar
📚 Resources
- Middleware Java Agent Jar Release for releases and release notes
- Official Middleware Java APM docs — Full documentation and advanced usage