watch 时ognl报NoSuchFieldException
- Dominant language
- Java
- Stars
- 37.6k
- Forks
- 7.6k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 4
Description
- [x] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。
### 环境信息
* `arthas-boot.jar` 或者 `as.sh` 的版本: 3.6.3
* Arthas 版本: 3.6.3
* 操作系统版本: Linux 4.18.0
* 目标进程的JVM版本: openjdk 1.8
* 执行`arthas-boot`的版本: 3.6.3
### 重现问题的步骤
```
[arthas@258677]$ watch -n 1 org.springframework.web.servlet.FrameworkServlet service '#hs=target.handlerMappings,
> #hs.{
> #hsi=#this,
> #cn=#hsi.getClass().getName(),
> (#cn.endsWith("RequestMappingHandlerMapping") || #cn.endsWith("ControllerEndpointHandlerMapping") || #cn.endsWith("WebMvcEndpointHandlerMapping")) ? (#hsi.mappingRegistry.registry.{
> #om = #this,
> #om.mapping.patternsCondition != null && (#pattern = #om.mapping.patternsCondition.patterns),
> #om.mapping.pathPatternsCondition != null && (#pattern = #om.mapping.pathPatternsCondition.patterns),
> #mtd=#om.mapping.methodsCondition.methods.toString()
> }) : ""
> }'
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 264 ms, listenerId: 91
watch failed, condition is: null, express is: #hs=target.handlerMappings,
#hs.{
#hsi=#this,
#cn=#hsi.getClass().getName(),
(#cn.endsWith("RequestMappingHandlerMapping") || #cn.endsWith("ControllerEndpointHandlerMapping") || #cn.endsWith("WebMvcEndpointHandlerMapping")) ? (#hsi.mappingRegistry.registry.{
#om = #this,
#om.mapping.patternsCondition != null && (#pattern = #om.mapping.patternsCondition.patterns),
#om.mapping.pathPatternsCondition != null && (#pattern = #om.mapping.pathPatternsCondition.patterns),
#mtd=#om.mapping.methodsCondition.methods.toString()
}) : ""
}, ognl.OgnlException: registry [java.lang.NoSuchFieldException: registry], visit /home/admin/logs/arthas/arthas.log for more details.
[arthas@258677]$ version
3.6.3
```
### 期望的结果
调试了看是有registry这个Field的,但是报错了。
### 实际运行的结果
实际运行结果,最好有详细的日志,异常栈。尽量贴文本。
```
watch failed, condition is: null, express is: #hs=target.handlerMappings,
#hs.{
#hsi=#this,
#cn=#hsi.getClass().getName(),
(#cn.endsWith("RequestMappingHandlerMapping") || #cn.endsWith("ControllerEndpointHandlerMapping") || #cn.endsWith("WebMvcEndpointHandlerMapping")) ? (#hsi.mappingRegistry.registry.{
#om = #this,
#om.mapping.patternsCondition != null && (#pattern = #om.mapping.patternsCondition.patterns),
#om.mapping.pathPatternsCondition != null && (#pattern = #om.mapping.pathPatternsCondition.patterns),
#mtd=#om.mapping.methodsCondition.methods.toString()
}) : ""
}, ognl.OgnlException: registry [java.lang.NoSuchFieldException: registry], visit /home/admin/logs/arthas/arthas.log for more details.
```
调试看报错是:

Contributor guide
Research direction
Start by reproducing the reported `watch` command on Arthas 3.6.3 with the stated Java and Linux environment, then inspect `/home/admin/logs/arthas/arthas.log` for the full OGNL exception. Trace why the `registry` field lookup reports `NoSuchFieldException` despite the field being present; done means the command can access it without the reported failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100