Springboot 2.3.0 application start failed when enabling actuator by add dependency of spring-boot-starter-actuator.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourc
ePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoun
dError: org/LatencyUtils/IntervalEstimator
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:
405) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-b
eans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-be
ans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-bean
s-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.
2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RE
LEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEA
SE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE
]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895) ~[spring-beans-
5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-conte
xt-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at com.test.MainApp.main(MainApp.java:19) [starter-0.0.1.jar:?]
Caused by: java.lang.NoClassDefFoundError: org/LatencyUtils/IntervalEstimator
at io.micrometer.core.instrument.simple.SimpleMeterRegistry.newTimer(SimpleMeterRegistry.java:90) ~[micrometer-core-1.5.1.jar:1.5.1]
at io.micrometer.core.instrument.MeterRegistry.lambda$timer$2(MeterRegistry.java:308) ~[micrometer-core-1.5.1.jar:1.5.1]
at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:612) ~[micrometer-core-1.5.1.jar:1.5.1]
at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:566) ~[micrometer-core-1.5.1.jar:1.5.1]
at io.micrometer.core.instrument.MeterRegistry.timer(MeterRegistry.java:306) ~[micrometer-core-1.5.1.jar:1.5.1]
at io.micrometer.core.instrument.Timer$Builder.register(Timer.java:539) ~[micrometer-core-1.5.1.jar:1.5.1]
Comment From: bclozel
Could you provide a sample application reproducing this problem? This dependency is brought by micrometer-core and should be there; I don't believe we're doing anything special for that besides applying the micrometer BOM.
Thanks!
Comment From: izeye
@yuanpli org.latencyutils:LatencyUtils jar file seems to be corrupted somehow. Deleting it from build cache and rebuilding the project will work if that's the case.
Comment From: izeye
Oops, @spring-buildmaster handled my comment as the expected feedback.
Comment From: yuanpli
Could you provide a sample application reproducing this problem? This dependency is brought by micrometer-core and should be there; I don't believe we're doing anything special for that besides applying the micrometer BOM.
Thanks!
@bclozel Hello, org.latencyutils.LatencyUtils is a runtime dependency at micrometer-core. This scope indicates that the dependency is not required for compilation, but is for execution. So it has to be included in spring at least.
Comment From: yuanpli
@yuanpli
org.latencyutils:LatencyUtilsjar file seems to be corrupted somehow. Deleting it from build cache and rebuilding the project will work if that's the case.
Hi, it doesn't work. :(
Comment From: izeye
@yuanpli Thanks for the feedback.
If that's not the case, I'm not sure how it could happen. As @bclozel asked you before, a sample project seems to be necessary to know what happens there.
For your information, this is what I used to check this issue before: https://github.com/izeye/sample-micrometer-spring-boot
Comment From: philwebb
Possibly related to #21507. @yuanpli Are you running your tests in IntelliJ?
Comment From: yuanpli
Possibly related to #21507. @yuanpli Are you running your tests in IntelliJ?
No, I am running in build jar
Comment From: bclozel
At this point we’ll need a sample project that reproduces the problem if we want to make progress. Can you provide that @yuanpli ?
Comment From: yuanpli
Hi all,
Sorry, this is not an issue. We just only copy compile dependencies in my project.
Thanks for all of your support!
Br, Yuanping
Comment From: mparlee
I think this should be re-opened. I didn't understand what yanpli's resolution was.
I encountered this issue upgrading an existing project to 2.3.0 and was only able to resolve it by reverting to 2.2.6.
Including the missing dependency did not resolve the issue.
Comment From: spencergibb
@mparlee
At this point we’ll need a sample project that reproduces the problem if we want to make progress. Can you provide that?
Comment From: shaswata09
Hi, the same issue occured for me as well but couldnt find any solutions... I'm also very new to spring and still in learning phase... Any help is appriciated...
Replication code base can be found at: https://github.com/shaswata09/spring-boot-practice-projects/tree/master
After I added dependency of actuator, the following error occured...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Other Infos: IDE = Intellij IDEA OS: Ubuntu 20.04.1
@spring-issuemaster
Comment From: snicoll
Replication code base can be found at: https://github.com/shaswata09/spring-boot-practice-projects/tree/master
Ignoring that weird my-alternate-repository repository that I've removed locally, the application starts correctly for me.
Comment From: shaswata09
Replication code base can be found at: https://github.com/shaswata09/spring-boot-practice-projects/tree/master
Ignoring that weird
my-alternate-repositoryrepositorythat I've removed locally, the application starts correctly for me.
Have you added the actuator dependency? In my case after adding the dependency it threw above mentioned runtime error.
Comment From: snicoll
Have you added the actuator dependency?
Yes. Please run the project from the command line (mvn spring-boot:run) as I suspect your IDE configuration is broken. This issue tracker is not the right place to get support on that though.
Comment From: nsarvar
@yuanpli
org.latencyutils:LatencyUtilsjar file seems to be corrupted somehow. Deleting it from build cache and rebuilding the project will work if that's the case.
that worked for me
Comment From: Sucran
Oh god! I found it really hard to understand this solution of @yuanpli about
I think this solution need to be describe as :
To change the maven or gradle script like this below:
compile("io.micrometer:micrometer-core:1.10.3")
to
compile("io.micrometer:micrometer-core:1.10.3") { exclude group: "org.latencyutils" } compile("org.latencyutils:LatencyUtils:2.0.3")
Comment From: omarelhussein
Deleting the build folder did not work in my case, I was able to fix this issue by updating IntelliJ to the latest version.