如何解决Tomcat jmxproxy返回"Attribute cannot be null"?

How to solve Tomcat jmxproxy returning "Attribute cannot be null"?

我们有一个应用程序 运行正在 Tomcat 上线。以下是 Tomcat 版本信息:

Server version: Apache Tomcat/7.0.96
Server built:   Sep 26 2019 18:42:39 UTC
Server number:  7.0.96.0
OS Name:        Linux
OS Version:     2.6.32-754.25.1.el6.x86_64
Architecture:   amd64
JVM Version:    1.8.0_232-b09
JVM Vendor:     Oracle Corporation

我正在尝试使用jmxproxy 获取一些监控信息。但是,当我 运行 curl -u 'user:pss' --url http://localhost:8080/manager/jmxproxy/?get=java.lang:type=Memory&att=HeapMemoryUsage&key=used 时出现以下错误:

root@server [user] curl -u 'user:pss' --url  http://localhost:8080/manager/jmxproxy/?get=java.lang:type=Memory&att=HeapMemoryUsage&key=used
[1] 18756
[2] 18757
root@server [user] Error - javax.management.RuntimeOperationsException: Exception occurred trying to invoke the getter on the MBean
javax.management.RuntimeOperationsException: Exception occurred trying to invoke the getter on the MBean
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:629)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:678)
        at org.apache.catalina.manager.JMXProxyServlet.getAttribute(JMXProxyServlet.java:131)
        at org.apache.catalina.manager.JMXProxyServlet.doGet(JMXProxyServlet.java:110)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:548)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Attribute cannot be null
        ... 29 more

知道我遗漏了什么或根本原因是什么吗?

谢谢!

我通过在“”之间放置 URL 解决了这个问题。所以下面的命令工作得很好。

$curl -u 'user:pss' --url "http://localhost:8080/manager/jmxproxy/?get=java.lang:type=Memory&att=HeapMemoryUsage&key=used"