I have configured spring boot 1.5.12 + ehcache and everything was working fine until I upgraded spring boot to 1.5.13
application.yml
has the below entry
spring:
cache:
jcache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
config: ehcache.xml
my ehcache.xml
is located under resources
directory
The error I am receiving is:
Caused by: java.lang.IllegalArgumentException: Cache configuration does not exist 'ServletContext resource [/ehcache.xml]'
at org.springframework.util.Assert.isTrue(Assert.java:92)
at org.springframework.boot.autoconfigure.cache.CacheProperties.resolveConfigLocation(CacheProperties.java:117)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.createCacheManager(JCacheCacheConfiguration.java:113)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.jCacheCacheManager(JCacheCacheConfiguration.java:97)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.CGLIB$jCacheCacheManager$1(<generated>)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047$$FastClassBySpringCGLIB$$a6ae7187.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.jCacheCacheManager(<generated>)
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.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 47 common frames omitted
It looks like spring boot has started searching for ehcache.xml
using servletContext resolver.
p.s. I had made no change in any of source code except the spring boot upgrade to 1.5.13
Am I missing some required configuration here?
EhCaching Storage Tiers are as follows: On-Heap Store: Java heap memory is used to store cache entries. Off-Heap Store: It stores cache entries into primary memory (RAM). Disk Store: It uses a disk to store cache entries. Clustered Store: Remote server is used to store cache entries.
Ehcache can be configured in two ways: The first way is through Java POJO where all configuration parameters are configured through Ehcache API. The second way is configuration through XML file where we can configure Ehcache according to provided schema definition.
I had figured out the fix for this problem. We need to specify the prefix classpath:
with the file name to make it work.
My application.yml
would look like this now
spring:
cache:
jcache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
config: classpath:ehcache.xml
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With