Unlock JVM Mysteries: How Arthas and AI Turn Debugging into a One‑Click Process
When a service’s P99 latency spikes to seconds and CPU hits 90% without logs, Arthas lets you inspect the JVM in real time without code changes, and its AI‑driven MCP extension automates command selection, enabling developers to diagnose, trace, decompile, and monitor issues through simple natural‑language prompts and Spring Boot integration.
Monitoring shows a service’s P99 response time jumping from 200 ms to 8 s, CPU usage over 90%, yet no error logs appear. The JVM appears as a black box, making traditional debugging (adding logs, JProfiler, GC logs) impractical.
Arthas: The Key to Opening the JVM Black Box
Arthas is an open‑source Java diagnostic tool from Alibaba that lets you observe the JVM internals without restarting or modifying code.
Use trace to find the slowest method call chain.
Use watch to monitor method parameters, return values, and exceptions in real time, eliminating the need for extra logging.
Use jad to decompile running bytecode back to Java source, confirming that the deployed code matches the repository.
Use thread to locate deadlocks and the threads consuming the most CPU.
Use dashboard to get an at‑a‑glance view of overall JVM health.
Typical troubleshooting commands:
# Find the thread with highest CPU usage
thread -n 3
# Trace the execution time of OrderService.createOrder
trace com.example.OrderService createOrder '#cost > 1000'
# Watch method parameters and return values
watch com.example.OrderService createOrder '{params, returnObj, throwExp}' -x 2These three commands often narrow the problem down to a specific method.
Arthas is regarded in the Java ops community as a combination of strace, perf and jstack, but with a far more user‑friendly interface.
Problem: Too Many Commands to Remember
While powerful, Arthas has a large command set— trace, watch, stack, tt, monitor, profiler, vmtool, ognl, etc.—each with numerous parameters. Users must decide which command to use, construct the correct expression syntax, execute, interpret results, and iterate, which is especially painful during late‑night incidents.
Complex investigations often require chaining multiple commands in a specific order, making knowledge transfer to less‑experienced teammates difficult.
Arthas MCP: Let AI Handle Diagnosis
"Service response is slow, recent code was deployed, help me investigate."
The AI component automatically plans a diagnostic path:
Invoke dashboard to view overall system load.
Run trace to locate the most time‑consuming method.
If an exception is found, use jad to decompile the target class and inspect its logic.
Execute sc -d to check class‑loading information and troubleshoot dependency conflicts.
Developers approve the plan, while the AI executes the steps.
How to Integrate into a Spring Boot Project
Two steps are required.
1️⃣ Add the Maven dependencies:
<properties>
<arthas.version>4.1.8</arthas.version>
</properties>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-spring-boot-starter</artifactId>
<version>${arthas.version}</version>
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-mcp-server</artifactId>
<version>${arthas.version}</version>
</dependency>2️⃣ Configure application.yml:
arthas:
app-name: ${spring.application.name}
ip: 127.0.0.1
http-port: 8563
mcp-endpoint: /admin/mcpAfter the application starts, the Arthas MCP server runs alongside Spring Boot and exposes the MCP endpoint at http://localhost:8563/admin/mcp.
arthas-skills: Empower Agents for Operations
If you use OpenClaw or Hermes, you can install the arthas-skills package to elevate operational automation.
npx skills add https://github.com/lltx/arthas-skills.gitOnce installed, a single natural‑language command can drive the entire diagnostic workflow, e.g.:
看一下我的应用的 JVM 占用情况,提供一个分析报告Another example shows how to fetch a Spring Bean and execute a query via natural language:
获取一下 userMapper 然后执行 Select 查询,通过 Spring Bean 的方式执行一下,看看当前有多少个用户The article also includes a diagram of the skills execution flow:
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
