Unable to manage EHCache under the JSR107 specification
linghengqian opened this issue · 1 comments
linghengqian commented
The following is my related introduction in POM.xml.
<!-- https://mvnrepository.com/artifact/org.ehcache/ehcache -->
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.9.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.cache/cache-api -->
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.kingbbode/spring-boot-ehcache-monitor -->
<dependency>
<groupId>com.github.kingbbode</groupId>
<artifactId>spring-boot-ehcache-monitor</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
</exclusion>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.vaadin/vaadin-bom -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>22.0.0</version>
<type>pom</type>
</dependency>
When I tried to introduce spring-boot-ehcache-monitor
, I found that EHCache under the JSR107 specification could not be managed, and it would throw an exception.
2021-12-10 12:42:38.851 WARN 15764 --- [ restartedMain] o.e.i.i.executor.PooledExecutionService : No default pool configured, services requiring thread pools must be configured explicitly using named thread pools
2021-12-10 12:42:39.016 INFO 15764 --- [ restartedMain] org.ehcache.core.EhcacheManager : Cache 'displaysASpecificStatisticalTable' created in EhcacheManager.
2021-12-10 12:42:39.090 INFO 15764 --- [ restartedMain] org.ehcache.core.EhcacheManager : Cache 'TbCompanyToTablePOCache' created in EhcacheManager.
2021-12-10 12:42:39.112 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=displaysASpecificStatisticalTable
2021-12-10 12:42:39.112 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=displaysASpecificStatisticalTable
2021-12-10 12:42:39.113 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=TbCompanyToTablePOCache
2021-12-10 12:42:39.113 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=TbCompanyToTablePOCache
2021-12-10 12:42:39.117 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=displaysASpecificStatisticalTable
2021-12-10 12:42:39.118 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=displaysASpecificStatisticalTable
2021-12-10 12:42:39.118 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=TbCompanyToTablePOCache
2021-12-10 12:42:39.118 INFO 15764 --- [ restartedMain] org.ehcache.jsr107.Eh107CacheManager : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=file./D./TwinklingLiftWorks/TestAndExperiment/JavaInIntelliJIDEA/lingh/lingh-springboot/lingh-web/target/classes/ehcache.xml,Cache=TbCompanyToTablePOCache
2021-12-10 12:42:40.175 INFO 15764 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path ''
2021-12-10 12:42:40.814 WARN 15764 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheHistoryStore' defined in class path resource [com/github/kingbbode/ehcache/monitor/EhcacheMonitorAutoConfiguration$EnableHistoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.kingbbode.ehcache.monitor.component.CacheHistoryStore]: Factory method 'cacheHistoryStore' threw exception; nested exception is java.lang.ClassCastException: org.springframework.cache.jcache.JCacheCacheManager cannot be cast to org.springframework.cache.ehcache.EhCacheCacheManager
2021-12-10 12:42:40.830 INFO 15764 --- [ restartedMain] org.ehcache.core.EhcacheManager : Cache 'displaysASpecificStatisticalTable' removed from EhcacheManager.
2021-12-10 12:42:40.849 INFO 15764 --- [ restartedMain] org.ehcache.core.EhcacheManager : Cache 'TbCompanyToTablePOCache' removed from EhcacheManager.
2021-12-10 12:42:40.881 INFO 15764 --- [ restartedMain] c.b.d.d.DynamicRoutingDataSource : dynamic-datasource start closing ....
2021-12-10 12:42:40.883 INFO 15764 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closing ...
2021-12-10 12:42:40.886 INFO 15764 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2021-12-10 12:42:40.886 INFO 15764 --- [ restartedMain] c.b.d.d.DynamicRoutingDataSource : dynamic-datasource all closed success,bye
2021-12-10 12:42:40.889 INFO 15764 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-12-10 12:42:40.904 INFO 15764 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-10 12:42:40.924 ERROR 15764 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheHistoryStore' defined in class path resource [com/github/kingbbode/ehcache/monitor/EhcacheMonitorAutoConfiguration$EnableHistoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.kingbbode.ehcache.monitor.component.CacheHistoryStore]: Factory method 'cacheHistoryStore' threw exception; nested exception is java.lang.ClassCastException: org.springframework.cache.jcache.JCacheCacheManager cannot be cast to org.springframework.cache.ehcache.EhCacheCacheManager
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) [spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) [spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) [spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) [spring-boot-2.6.1.jar:2.6.1]
at com.lingh.LinghWebApplication.main(LinghWebApplication.java:13) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_302]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_302]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_302]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_302]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.6.1.jar:2.6.1]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.kingbbode.ehcache.monitor.component.CacheHistoryStore]: Factory method 'cacheHistoryStore' threw exception; nested exception is java.lang.ClassCastException: org.springframework.cache.jcache.JCacheCacheManager cannot be cast to org.springframework.cache.ehcache.EhCacheCacheManager
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.13.jar:5.3.13]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.13.jar:5.3.13]
... 24 common frames omitted
Caused by: java.lang.ClassCastException: org.springframework.cache.jcache.JCacheCacheManager cannot be cast to org.springframework.cache.ehcache.EhCacheCacheManager
at com.github.kingbbode.ehcache.monitor.component.CacheHistoryStore.<init>(CacheHistoryStore.java:24) ~[spring-boot-ehcache-monitor-1.1.jar:na]
at com.github.kingbbode.ehcache.monitor.EhcacheMonitorAutoConfiguration$EnableHistoryConfiguration.cacheHistoryStore(EhcacheMonitorAutoConfiguration.java:27) ~[spring-boot-ehcache-monitor-1.1.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_302]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_302]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_302]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_302]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.13.jar:5.3.13]
... 25 common frames omitted
进程已结束,退出代码为 0
Can anyone provide solutions?
linghengqian commented
After a few months, I realized that maybe this component didn't support the ehcache version that high, and there was a major refactoring behind ehCache.