Hello everyone,

I've just upgraded Spring Boot from 2.0.1 to 2.0.2 and now our application doesn't startup anymore because of a NoSuchMethodError in the actuator metrics module.

Caused by: java.lang.NoSuchMethodError: com.hazelcast.spring.cache.HazelcastCache.getNativeCache()Lcom/hazelcast/core/IMap;
    at org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.getMeterBinder(HazelcastCacheMeterBinderProvider.java:35)
    at org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.getMeterBinder(HazelcastCacheMeterBinderProvider.java:30)
    at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.lambda$getMeterBinder$0(CacheMetricsRegistrar.java:76)
    at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$null$2(LambdaSafe.java:306)
    at org.springframework.boot.util.LambdaSafe$LambdaSafeCallback.invoke(LambdaSafe.java:162)
    at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$invokeAnd$3(LambdaSafe.java:305)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.getMeterBinder(CacheMetricsRegistrar.java:78)
    at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.bindCacheToRegistry(CacheMetricsRegistrar.java:62)
    at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCacheToRegistry(CacheMetricsRegistrarConfiguration.java:79)
    at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.lambda$bindCacheManagerToRegistry$0(CacheMetricsRegistrarConfiguration.java:73)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCacheManagerToRegistry(CacheMetricsRegistrarConfiguration.java:73)
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCachesToRegistry(CacheMetricsRegistrarConfiguration.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
    ... 18 common frames omitted

I assume the error is related to the type cast which was removed in this commit in HazelcastCacheMeterBinderProvider: https://github.com/spring-projects/spring-boot/commit/c826310fd1bb69dcc7df151a1992f39219565276#diff-733fa2b8acbd48ce952884562aef69a4

Thanks in advance.

Comment From: wilkinsona

@Koizumi85 Thanks for report. I've edited your description to replace "guys" with "everyone". While it may seem a small thing, some people feel excluded by "guys" and we don't want them to.

Comment From: wilkinsona

What version of Hazelcast are you using? A binary incompatible change was made in 3.9.4 which means that Spring Boot 2.0.2 requires 3.9.4 and 2.0.1 requires 3.9.3 (or earlier).

Comment From: Koizumi85

@wilkinsona Thanks for the hint. I wasn't aware, that we set a specific hazelcast version in our gradle file. Removed it and it works with the boot-managed version like a charm. :+1:

Comment From: wilkinsona

Excellent. Thanks for following up.

Comment From: ravichappa22

this issue again back with Hazelcast 4.2.1 combined with springboot 2.2.9 @wilkinsona

Comment From: snicoll

@ravichappa22 I don't think that's accurate considering that Spring Boot 2.2.9 manages Hazelcast 3.12.8. You can't expect to be able to switch to a new major version of Hazelcast that didn't exist when this version of Spring Boot was relased.