error when calling Caching.getCachingProvider

615 views
Skip to first unread message

Pep Grifell

unread,
Mar 5, 2019, 7:39:05 AM3/5/19
to ehcache-users
  1. What version of Ehcache you are currently using;  3.6.1
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);  JCache 1.0.0
  4. Providing JDK and OS versions maybe useful as well:  Windows 10, JDK: 1.8.0_144

        I'm using EHCache with the JCache API:

URL config = getConfigURL();  / read an xml configuration file
CachingProvider provider = Caching.getCachingProvider(); // the error is produced in this line
CacheManager jcacheManager = provider.getCacheManager( config.toURI(), getClass().getClassLoader());

        When executing the code, I get this error:


2019-03-05 13:33:15,798 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /RemoteProcessorWeb/: java.util.ServiceConfigurationError: javax.cache.spi.CachingProvider: Provider org.ehcache.jsr107.EhcacheCachingProvider not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at javax.cache.Caching$CachingProviderRegistry$1.run(Caching.java:438)
at javax.cache.Caching$CachingProviderRegistry$1.run(Caching.java:432)
at java.security.AccessController.doPrivileged(Native Method)
at javax.cache.Caching$CachingProviderRegistry.getCachingProviders(Caching.java:432)
at javax.cache.Caching$CachingProviderRegistry.getCachingProvider(Caching.java:519)
at javax.cache.Caching$CachingProviderRegistry.getCachingProvider(Caching.java:466)
at javax.cache.Caching.getCachingProvider(Caching.java:217)

 
Any idea of the error ? Thanks !!!


Rudra Simha Reddy Balankari

unread,
Mar 8, 2019, 7:04:18 PM3/8/19
to ehcach...@googlegroups.com
If you are using a JCache Provider, you can autowire the cache manager.

You have to have the configuration in ehcache.xml and include it the src folder. Also you have to add the property 
spring.cache.jcache.config=classpath:ehcache.xml in your application.properties  

The other approach would be using the Mutable Configuration and get to the cache provider.

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/353bf8ac-551e-4baf-bfc3-3f9eb42488eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages