Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用arthas出现异常:com.taobao.arthas.core.command.express.ExpressException: java.lang.NullPointerException: target is null for method getBean #2942

Open
1 task
Uncle-Xi opened this issue Nov 10, 2024 · 3 comments

Comments

@Uncle-Xi
Copy link

  • 我已经在 issues 里搜索,没有重复的issue。

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: 4.0.2、3.4.3、3.6.9、3.5.5 都一样的结果
  • Arthas 版本: 4.0.2、3.4.3、3.6.9、3.5.5
  • 操作系统版本: windows 11
  • 目标进程的JVM版本: 1.8
  • 执行arthas-boot的版本: 4.0.2、3.4.3、3.6.9、3.5.5

重现问题的步骤

1、pom导入依赖

com.taobao.arthas
arthas-tunnel-server
4.0.2


com.taobao.arthas
arthas-spring-boot-starter
4.0.2

2、yml配置了
spring:
arthas:
enabled: true
arthas:
ip: 0.0.0.0

3、在控台执行命令就报错(arthas idea plugin 拷贝的命令 —— 命令本身没问题)

http://localhost:8563/

期望的结果

What do you expected from the above steps?

正常执行命令

实际运行的结果

实际运行结果,最好有详细的日志,异常栈。尽量贴文本。



2024-11-10 22:06:49 [arthas-command-execute] WARN  c.t.a.c.command.klass100.OgnlCommand -ognl: failed execute express: #[email protected]@context,#springContext.getBean("authMetadataService").permissionOptions()
com.taobao.arthas.core.command.express.ExpressException: java.lang.NullPointerException: target is null for method getBean
	at com.taobao.arthas.core.command.express.OgnlExpress.get(OgnlExpress.java:39)
	at com.taobao.arthas.core.command.klass100.OgnlCommand.process(OgnlCommand.java:106)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
	at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: target is null for method getBean
	at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)
	at ognl.ASTMethod.getValueBody(ASTMethod.java:72)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
	at ognl.SimpleNode.getValue(SimpleNode.java:206)
	at ognl.ASTChain.getValueBody(ASTChain.java:128)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
	at ognl.SimpleNode.getValue(SimpleNode.java:206)
	at ognl.ASTSequence.getValueBody(ASTSequence.java:47)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
	at ognl.SimpleNode.getValue(SimpleNode.java:206)
	at ognl.Ognl.getValue(Ognl.java:408)
	at ognl.Ognl.getValue(Ognl.java:480)
	at ognl.Ognl.getValue(Ognl.java:460)
	at com.taobao.arthas.core.command.express.OgnlExpress.get(OgnlExpress.java:36)
	... 14 common frames omitted




@WangJi92
Copy link
Contributor

hello, 我这里也测试了一下 ,你可能需要携带 -c classloader hashcode ,Caused by: java.lang.NullPointerException: target is null for method getBean ,获取静态的spring context 为null

@Uncle-Xi

[arthas@22736]$ ognl -x 3 '#springContext=@com.wangji92.arthas.plugin.demo.common.ApplicationContextProvider@context,#springContext.getBean("commonController").innerAnonymousClass()'
Failed to execute ognl, exception message: java.lang.NullPointerException: target is null for method getBean, please check $HOME/logs/arthas/arthas.log for more details.
[arthas@22736]$ ognl -x 3 '#springContext=@com.wangji92.arthas.plugin.demo.common.ApplicationContextProvider@context,#springContext.getBean("commonController").innerAnonymousClass()' -c 17c2f048
@String[ok]

@WangJi92
Copy link
Contributor

不过推荐你换个命令 ,这个命令更加灵活 https://arthas.aliyun.com/doc/vmtool.html ,不需要配置spring context ,任何项目都可以
image

@Uncle-Xi
Copy link
Author

Uncle-Xi commented Nov 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants