You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exporter Pushgateway runtime issue in versions 1.3.4 and above #1411
Exception in thread (...) java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: class io.prometheus.metrics.expositionformats.PrometheusProtobufWriter is not available
at io.prometheus.metrics.exporter.pushgateway.PushGateway.<init>(PushGateway.java:99)
at io.prometheus.metrics.exporter.pushgateway.PushGateway.<init>(PushGateway.java:77)
at io.prometheus.metrics.exporter.pushgateway.PushGateway$Builder.build(PushGateway.java:456)
(...)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.RuntimeException: class io.prometheus.metrics.expositionformats.PrometheusProtobufWriter is not available
Thanks for answering, yeah I started comparing your example with my codebase and I think I've found what causes the issue. So 1 difference I've found is that I'm using minimizeJar tag under configuration in maven-shade-plugin.
When minimizeJar is set to true then we have runtime issue and calling jar tf myJar.jar | grep PrometheusProtobufWriter yields
So pom.xml contains minimizeJar tag. When you compile and run it you will get
Exception in thread "main" java.lang.RuntimeException: class io.prometheus.metrics.expositionformats.PrometheusProtobufWriter is not available
at io.prometheus.metrics.exporter.pushgateway.PushGateway.<init>(PushGateway.java:102)
at io.prometheus.metrics.exporter.pushgateway.PushGateway.<init>(PushGateway.java:77)
at io.prometheus.metrics.exporter.pushgateway.PushGateway$Builder.build(PushGateway.java:483)
at PushGatewayApp.runSimpleTest(PushGatewayApp.java:15)
at PushGatewayApp.main(PushGatewayApp.java:10)
You can get it working either with setting minimizeJar to false or downgrading dependencies down to 1.3.3 version. It looks like minimizeJar from maven shade plugin messes somehow with reflection introduced in 1.3.4.
@zeitlinger I was playing with this maven shade filtering. Interestingly enough when you change (in your approach) <include>io/prometheus/metrics/expositionformats/internal/PrometheusProtobufWriterImpl</include>
into <include>**</include>
it starts working. I'm not sure why tbh but as long as it works I'm good.
Then I thought I would update version to the newest one, I changed version to 1.3.9 and it stopped working again (fix from 1.3.8 does not work in 1.3.9). Have you changed something regarding shading in 1.3.9?
prometheus-metrics-exposition-formats has to be used instead of prometheus-metrics-exposition-formats-no-protobuf. Is it in accordance with how it is supposed to be? I don't know, you can tell me :d.
prometheus-metrics-exposition-formats has to be used instead of prometheus-metrics-exposition-formats-no-protobuf. Is it in accordance with how it is supposed to be? I don't know, you can tell me :d.
Yes, this is the result of the #1411 bug fix.
A docs PR would be highly welcome 😄
Hi I’d like to work on a docs PR for this.
I’m planning to add a short troubleshooting note for shaded jars with minimizeJar=true and document the Maven Shade workaround confirmed in this issue.
@ADITYA-CODE-SOURCE that filtering was valid for version 1.3.10.
Please check whether it works with latest versions of library 1.6.0, 1.6.1.
There is a chance that something has changed since then.
Activity
zeitlinger commentedon Jun 5, 2025
From the description it looks exactly like https://github.com/prometheus/client_java/tree/main/integration-tests/it-pushgateway
Please include a full example that demonstrates the bug.
rafauu commentedon Jun 5, 2025
Thanks for answering, yeah I started comparing your example with my codebase and I think I've found what causes the issue. So 1 difference I've found is that I'm using minimizeJar tag under configuration in maven-shade-plugin.
When minimizeJar is set to true then we have runtime issue and calling
jar tf myJar.jar | grep PrometheusProtobufWriteryieldsWhen minimizeJar is set to false then it works and calling command (jar tf...) yields
I'm gonna create full repro with minimal example soon.
rafauu commentedon Jun 5, 2025
Here is repro of the issue: https://github.com/rafauu/prometheus-pushgateway/tree/main
So pom.xml contains minimizeJar tag. When you compile and run it you will get
You can get it working either with setting minimizeJar to false or downgrading dependencies down to 1.3.3 version. It looks like minimizeJar from maven shade plugin messes somehow with reflection introduced in 1.3.4.
rafauu commentedon Jun 9, 2025
I can see it was addressed before prometheus/jmx_exporter#1133
edit: although issue is a little bit different, it is still related to shading
rafauu commentedon Jun 23, 2025
Hi @zeitlinger, any new insights on that?
zeitlinger commentedon Jun 24, 2025
To reproduce:
The class that is missing is now loaded via reflection - and I guess this is not detected when minimizing:
client_java/prometheus-metrics-exposition-textformats/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java
Line 26 in 66f4dc8
This change below adds the class back according to the build output
It still is not included it the final jar - maybe that's a bug in the shade plugin.
rafauu commentedon Jul 12, 2025
@zeitlinger I was playing with this maven shade filtering. Interestingly enough when you change (in your approach)
<include>io/prometheus/metrics/expositionformats/internal/PrometheusProtobufWriterImpl</include>into
<include>**</include>it starts working. I'm not sure why tbh but as long as it works I'm good.
Then I thought I would update version to the newest one, I changed version to 1.3.9 and it stopped working again (fix from 1.3.8 does not work in 1.3.9). Have you changed something regarding shading in 1.3.9?
rafauu commentedon Jul 12, 2025
Ok, I've figured out how to make it work in versions 1.3.9 and 1.3.10. Such filtering is required:
prometheus-metrics-exposition-formatshas to be used instead ofprometheus-metrics-exposition-formats-no-protobuf. Is it in accordance with how it is supposed to be? I don't know, you can tell me :d.zeitlinger commentedon Jul 14, 2025
Yes, this is the result of the #1411 bug fix.
A docs PR would be highly welcome 😄
ADITYA-CODE-SOURCE commentedon May 8, 2026
Hi I’d like to work on a docs PR for this.
I’m planning to add a short troubleshooting note for shaded jars with
minimizeJar=trueand document the Maven Shade workaround confirmed in this issue.rafauu commentedon May 8, 2026
@ADITYA-CODE-SOURCE that filtering was valid for version 1.3.10.
Please check whether it works with latest versions of library 1.6.0, 1.6.1.
There is a chance that something has changed since then.
docs: document PushGateway shading workaround (#2106)
docs: document PushGateway shading workaround (#2106)