Micrometer: java.lang.ClassNotFoundException: io.micrometer.core.instrument.stats.quantile.Quantiles

Created on 28 Aug 2019  路  5Comments  路  Source: micrometer-metrics/micrometer

Getting java.lang.ClassNotFoundException: io.micrometer.core.instrument.stats.quantile.Quantiles exception when using spring-boot-actuator-starter and setting up a data source.

version used:
org.springframework.boot.spring-boot-starter-actuator:2.1.7.RELEASE

also worth noting:
As a transitive dependency, I already load
io.micrometer.micrometer-registry-prometheus:1.1.1

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceM$
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:380)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
        at com.getbux.broker.backoffice.app.App.main(App.java:14)
Caused by: java.lang.NoClassDefFoundError: io/micrometer/core/instrument/stats/quantile/Quantiles
        at com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory.create(MicrometerMetricsTrackerFactory.java:20)
        at com.zaxxer.hikari.pool.HikariPool.setMetricsTrackerFactory(HikariPool.java:286)
        at com.zaxxer.hikari.HikariDataSource.setMetricsTrackerFactory(HikariDataSource.java:243)
        at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration.bindMetricsRegistryToHikariDataSource(DataSourcePoolMetri$
        at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration.bindMetricsRegistryToHikariDataSources(DataSourcePoolMetr$
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:708)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
        ... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.micrometer.core.instrument.stats.quantile.Quantiles
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 29 common frames omitted

Does anyone have a clue what I am doing wrong, or how to fix this exception?

Most helpful comment

I was using:

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>2.7.2</version>
        </dependency>

now I switched to:

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>3.3.1</version>
        </dependency>

which seems to have solved the problem.

Thanks for your help guys, I appreciate it.

All 5 comments

@gorjan-bux I suspect you have a corrupted jar for the io.micrometer:micrometer-core dependency in your cache. Please try deleting the jar in the cache and then start your application again.

@gorjan-bux Sorry, I overlooked the class which has triggered the ClassNotFoundException. Ignore the first comment. There's no io.micrometer.core.instrument.stats.quantile.Quantiles in io.micrometer:micrometer-core:1.1.1. Based on the stack trace, it seems you're using HikariCP which is not compatible with Micrometer.

@izeye Thanks for the fast response.
For some reason we are using a custom version HikariCP, and I will investigate this further and post an update.

For some reason we are using a custom version HikariCP, and I will investigate this further and post an update.

Micrometer integration should work well with official versions of HikariCP.
Your stacktrace doesn't match with the HikariCP source: https://github.com/brettwooldridge/HikariCP/blob/086bf18389282d1a7484e243d6af49890cec4fd7/src/main/java/com/zaxxer/hikari/metrics/micrometer/MicrometerMetricsTrackerFactory.java

If you can use official versions of HikariCP, that would be best.

I was using:

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>2.7.2</version>
        </dependency>

now I switched to:

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>3.3.1</version>
        </dependency>

which seems to have solved the problem.

Thanks for your help guys, I appreciate it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samanthacatania picture samanthacatania  路  4Comments

adrianboimvaser picture adrianboimvaser  路  3Comments

ericsogm picture ericsogm  路  3Comments

nugnoperku picture nugnoperku  路  4Comments

jonatan-ivanov picture jonatan-ivanov  路  3Comments