Java Api Debug
Overview
Use this skill to analyze Java interface errors from logs, code snippets, stack traces, and failing request descriptions. It is optimized for backend projects that follow a typical controller -> service -> mapper flow and need fast fault isolation plus a concrete next-step fix plan.
Quick Start
When this skill triggers:
- Gather the failure evidence first: error log, stack trace, request path, request parameters, and expected behavior.
- Identify the failing layer before proposing fixes: controller, service, mapper, SQL, dependency wiring, or environment/config.
- Produce a diagnosis that maps
symptom -> likely cause -> verification step -> recommended fix. - Keep the response practical. Prefer file-level or class-level targets over generic theory.
If detailed heuristics are needed, read references/troubleshooting.md.
Workflow
1. Normalize the input
Extract and restate the key facts:
- request path or interface name
- HTTP method
- exception type
- first business-relevant stack frame
- affected module, class, or package
- whether the issue is reproducible or intermittent
If the user only provides a vague symptom such as "the API returns 500", ask for or infer the minimum missing context from logs, controller mapping, and recent changes.
2. Classify the failure layer
Use this decision path:
controllerif the issue looks like routing, parameter binding, validation, serialization, missing annotations, or response wrappingserviceif the issue looks like business branching, null handling, transaction boundaries, remote calls, or DTO/VO conversionmapperif the issue looks like SQL execution, MyBatis parameter mapping, result mapping, table or column mismatch, or dynamic SQL generationconfigurationif the issue looks like datasource, Redis, Nacos, port, bean scanning, or profile/environment loading
When multiple layers are involved, identify the first failing layer and then note the downstream effects separately.
3. Inspect by layer
Controller checks
Review:
@RequestMapping,@GetMapping,@PostMappingpath correctness- request object annotations such as
@RequestBody,@RequestParam,@PathVariable - validation annotations and global exception handlers
- response conversion issues such as enum/date/json serialization
Common signals:
405,404,HttpMessageNotReadableException- missing required parameter
- request body parse failure
- enum conversion failure
Service checks
Review:
- null inputs and unchecked service return values
- branch conditions and status transitions
- transaction boundaries and rollback expectations
- remote dependency calls, cache reads, or permission guards
Common signals:
NullPointerException- business assertion failures
- partial updates
- data written but not committed
Mapper checks
Review:
- mapper XML or annotation SQL
- parameter names and
@Paramusage - result mapping and field aliasing
- dynamic SQL conditions and empty collections
- table or column existence and database compatibility
Common signals:
BindingExceptionBadSqlGrammarExceptionTooManyResultsException- returned row count mismatch
4. Produce the diagnosis
Use this output shape:
现象:
初步判断:
定位依据:
优先检查:
建议修复:
风险与回归点:
Keep the diagnosis concise and action-oriented. If there is uncertainty, rank the top 2-3 likely causes instead of pretending certainty.
Output Standards
- Prefer concrete class or file targets such as
OrderController,UserServiceImpl, orOrderMapper.xml. - Quote the first meaningful stack frame rather than dumping the full stack trace.
- Separate root cause from follow-on symptoms.
- When suggesting a fix, include at least one verification step.
- When the issue likely comes from SQL or MyBatis, say exactly which input, mapping, or query shape should be checked.
Example Requests
- "Use $java-api-debug to analyze this 500 error from my Spring Boot order interface."
- "Use $java-api-debug to locate whether this exception comes from controller, service, or mapper."
- "Use $java-api-debug to read this stack trace and tell me the likely root cause plus fix steps."
References
- Read references/troubleshooting.md when you need a deeper checklist for common Java API error patterns.




