Working on SpringBoot upgrade from 2.7.7 to 3.2.4, And my build is failing with below error –
Caused by: io.micrometer.core.instrument.config.InvalidConfigurationException: Cache name 'userCache' results in an invalid JMX name
There is no change as such, eveything coming from Spring Boot Parent Pom –
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
ehcache.xml –
<cache alias="userCache">
<key-type>java.lang.String</key-type>
<value-type>com.model.User</value-type>
<expiry>
<ttl unit="hours">72</ttl>
</expiry>
<listeners>
<listener>
<class>com.logging.CacheEventLogger</class>
<event-firing-mode>ASYNCHRONOUS</event-firing-mode>
<event-ordering-mode>UNORDERED</event-ordering-mode>
<events-to-fire-on>CREATED</events-to-fire-on>
<events-to-fire-on>EXPIRED</events-to-fire-on>
</listener>
</listeners>
<resources>
<heap unit="entries">10000</heap>
<offheap unit="MB">10</offheap>
</resources>
<jsr107:mbeans enable-management="false" enable-statistics="false"/> <!-- not Working -->
</cache>
`enter code here`....
Before throwing error – it show registering the cache and after error removing –
{"@timestamp":"2024-05-17T17:43:24.4177743-05:00","@version":"1","message":"Cache 'userProfileCache' created in EhcacheManager.","logger_name":"org.ehcache.core.EhcacheManager","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2024-05-17T17:43:24.4277977-05:00","@version":"1","message":"Allocating 10.0MB in chunks","logger_name":"org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2024-05-17T17:43:24.4383648-05:00","@version":"1","message":"Cache 'userCache' created in EhcacheManager.","logger_name":"org.ehcache.core.EhcacheManager","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2024-05-17T17:43:24.9765181-05:00","@version":"1","message":"Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration': Failed to instantiate [org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration]: Constructor threw exception","logger_name":"org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext","thread_name":"main","level":"WARN","level_value":30000}
{"@timestamp":"2024-05-17T17:43:24.9848795-05:00","@version":"1","message":"Cache 'userProfileCache' removed from EhcacheManager.","logger_name":"org.ehcache.core.EhcacheManager","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2024-05-17T17:43:24.987382-05:00","@version":"1","message":"Cache 'userCache' removed from EhcacheManager.","logger_name":"org.ehcache.core.EhcacheManager","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2024-05-17T17:43:25.0001296-05:00","@version":"1","message":"Stopping service [Tomcat]","logger_name":"org.apache.catalina.core.StandardService","thread_name":"main","level":"INFO","level_value":20000}```