0

This is a follow up of my solved config problem. Just for brief summary:

I try to enable Spring Boot Actuator (together with Swagger) and have in the pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

with the following config in the yml-file:

springdoc:
  api-docs:
    enabled: true
  show:
    actuator: true  


management:
  endpoints:
    web:
      exposure:
        include: "*"

When I now launch the application I get the following stack trace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration': Injection of autowired d
ependencies failed; nested exception is java.lang.AbstractMethodError: Receiver class com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory does not define or inherit an implementation of the resolved method 'abstract com.zaxxer.hikari
.metrics.MetricsTracker create(java.lang.String, com.zaxxer.hikari.metrics.PoolStats)' of interface com.zaxxer.hikari.metrics.MetricsTrackerFactory.
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
Caused by: java.lang.AbstractMethodError: Receiver class com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory does not define or inherit an implementation of the resolved method 'abstract com.zaxxer.hikari.metrics.MetricsTracker creat
e(java.lang.String, com.zaxxer.hikari.metrics.PoolStats)' of interface com.zaxxer.hikari.metrics.MetricsTrackerFactory.
    at com.zaxxer.hikari.pool.HikariPool.setMetricsTrackerFactory(HikariPool.java:273)
    at com.zaxxer.hikari.HikariDataSource.setMetricsTrackerFactory(HikariDataSource.java:243)
    at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration.bindMetricsRegistryToHikariDataSource(DataSourcePoolMetricsAutoConfiguration.java:127)
    at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration.bindMetricsRegistryToHikariDataSources(DataSourcePoolMetricsAutoConfiguration.java:119)
    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:725)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
    ... 18 common frames omitted

I tried to search for solution and found in Github an issue. Since I'm using Spring Boot 2.4.5 I would have expected to be solved already. But doesn't seem so.

  1. How to apply the suggested patch from Gradle to Maven?
  2. Is there another solution for this issue? e.g. some configuration?
LeO
  • 4,238
  • 4
  • 48
  • 88
  • I created a test project and cannot reproduce your problem. Please show your pom.xml and the whole application.yaml – Simon Martinelli May 05 '21 at 09:30
  • 1
    It looks like Hikari's `MetricsTrackerFactory` interface and its `MicrometerMetricsTrackerFactory` implementation are not compatible with each other. That would suggest that they've been loaded from different jar files. You could use `mvn dependency:tree` to see if Hikari appears multiple times in your application's dependencies or you could run your application with `-verbose:class` to see from where the two classes are being loaded. – Andy Wilkinson May 05 '21 at 09:31
  • @SimonMartinelli: Since the `pom.xml` is quite complex and has several parents included as well I can hardly share it. – LeO May 05 '21 at 09:53
  • @AndyWilkinson: I share the information about verbose:class at https://ctxt.io/2/AACg-RhsFg (the previous link simply included a wrong file). The depency:tree won't include anything like Metric. Anything else? – LeO May 05 '21 at 10:58
  • Thx for the hint from @AndyWilkinson I figured out that the `Hikari` is loaded from two different Maven repository paths. When I cleaned them only one path is left and therefore it succeeds (until I'm facing the next issue ;-)) – LeO May 05 '21 at 11:09

0 Answers0