[alibaba/arthas]已经获取到了applicatonContext的类名全路径、如何直接通过该路径调用getBean

2023-12-12 52 views
3

ognl -x 3 '#springContext=@org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@this,#springContext.getBean("something").toString()'

报错:Failed to execute ognl, exception message: ognl.OgnlException: Could not get static field this from class org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext [java.lang.ClassNotFoundException: Unable to resolve class: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext]

回答

6

我使用vmtool 成功了 但是vmtool调用带有POJO参数的方法会报[java.lang.ClassNotFoundException]找不到我定义的POJO; 看起来是上面ognl那个无法访问内置的类、vmtool无法访问自定义的类、、、 是这个理么??

0

vmtool -x 3 --action getInstances --className org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext --express 'instances[0].getBean("someThing").toString()' //成功 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext --express 'instances[0].getBean("someThing").toS(new 我自定义的类())' //找不到类