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

JMX scrape failed: java.lang.NullPointerException mx.JmxScraper.scrapeBean(JmxScraper.java:156 #362

Closed
AviNachman opened this issue Mar 5, 2019 · 10 comments · Fixed by #444

Comments

@AviNachman
Copy link

Hey
i running with jmx_prometheus_javaagent-0.11.0.jar and getting on startup this exception below
can u please advice?
i try also to debug and did not got any logs(https://www.robustperception.io/viewing-logs-for-the-jmx-exporter)

io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector collect
SEVERE: JMX scrape failed: java.lang.NullPointerException
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.scrapeBean(JmxScraper.java:156)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.doScrape(JmxScraper.java:117)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.collect(JmxCollector.java:460)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:216)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:137)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer$HTTPMetricHandler.handle(HTTPServer.java:59)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)

@brian-brazil
Copy link
Contributor

The attributes look to be null, which shouldn't be possible. What are you using this with?

@AviNachman
Copy link
Author

Hey Brian
i running on tomcat application and configure it with:
export JAVA_OPTS="${JAVA_OPTS} -javaagent:/scuser/nft/user/odonft01/jmx_prometheus_javaagent-0.11.0.jar=9099:/scuser/nft/user/odonft01/config.yml"

at config.yml i am using the example got from the site:
https://github.com/prometheus/jmx_exporter/blob/master/example_configs/tomcat.yml

@brian-brazil
Copy link
Contributor

From the debug output, can you tell which mBean is causing this?

@AviNachman
Copy link
Author

Thanks Brian, i configure the debug output as shown here:
https://www.robustperception.io/viewing-logs-for-the-jmx-exporter
but did not got any out... only on catalina.out can you direct me i configure it like that:
export JAVA_OPTS="${JAVA_OPTS} -Djava.util.logging.config.file=/scuser/nft/user/odonft01/logging.properties
and create logging.properties with the values on home directory (/scuser/nft/user/odonft01/)

@brian-brazil
Copy link
Contributor

That's odd, you'd have to debug it yourself. You could also insert some print statements above the line that has the exception to figure out what's going on.

@AviNachman
Copy link
Author

Thanks Brian,
I debugged the code and found that a class in my application code returns null value of attributeInfo when getMBeanInfo is called.

it fails on JmxScraper line 156:
for (Attribute attribute : attributes.asList()) {

so i added before it a null check:
if(attributes == null){
return;
}

then issue resolved.
could u please tell me if i could change code in jmx_exporter and how i am doing it in order to solve the issue.
or you can assist with it?

@brian-brazil
Copy link
Contributor

We should be resilient to this, but that's also a bug in your application that should be fixed.

@AviNachman
Copy link
Author

Thanks i will check it but can u also give support for that?

@brian-brazil
Copy link
Contributor

If you want to put that in a PR and add a log line, that'd be great.

@AviNachman
Copy link
Author

Hey Brian below is the pull request:
#363

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

Successfully merging a pull request may close this issue.

2 participants