[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Spring annotation cache: CacheDecoratorFactory not configured for defaultCache  XML
Forum Index -> Ehcache
Author Message
giandrea

neo

Joined: 06/25/2012 11:39:11
Messages: 5
Offline

I'm trying to use Sping Annotation cache with EhCache. So, for first, I added the dependency to my pom.xml and configured the application-context.xml as:

Code:
    <ehcache:annotation-driven cache-manager="cacheManager" />
     
     <ehcache:config cache-manager="cacheManager">
     	<ehcache:evict-expired-elements interval="60" />
     </ehcache:config>
     
     <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
     	<property name="configLocation"  value="ehcache.xml"/>
     </bean>


This is the ehcache.xml configuration file:

<?xml version="1.0" encoding="UTF-8"?>

Code:
   <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
         <defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
         <cache name="alfresco" maxElementsInMemory="10" eternal="true" overflowToDisk="false" />
     </ehcache>


for last, I added the Annontation @Cachable to the methods that need to be cached:

@Cacheable(value="alfresco")
public EMContents getContents(RestTemplate restTemplate, String ticket, String webScriptUrl, String em_name)

At this point, when I start the web application, it seems to work fine, but I get this error message:

Code:
    25 Jun 2012 19:40:07  INFO EhCacheManagerFactoryBean:100 - Initializing EHCache CacheManager
     25 Jun 2012 19:40:07 DEBUG ConfigurationFactory:148 - Configuring ehcache from InputStream
     25 Jun 2012 19:40:07 DEBUG BeanHandler:271 - Ignoring ehcache attribute xmlns:xsi
     25 Jun 2012 19:40:07 DEBUG BeanHandler:271 - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
     25 Jun 2012 19:40:07 DEBUG PropertyUtil:88 - propertiesString is null.
     25 Jun 2012 19:40:07 DEBUG CacheManager:605 - No disk store path defined. Skipping disk store path conflict test.
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:184 - No CacheManagerEventListenerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:949 - No BootstrapCacheLoaderFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:923 - CacheWriter factory not configured. Skipping...
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:949 - No BootstrapCacheLoaderFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:923 - CacheWriter factory not configured. Skipping...
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:949 - No BootstrapCacheLoaderFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:923 - CacheWriter factory not configured. Skipping...
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:949 - No BootstrapCacheLoaderFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:923 - CacheWriter factory not configured. Skipping...
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:949 - No BootstrapCacheLoaderFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:923 - CacheWriter factory not configured. Skipping...
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory class specified. Skipping...
     25 Jun 2012 19:40:07 DEBUG Cache:1183 - Initialised cache: alfresco_action
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:331 - CacheDecoratorFactory not configured. Skipping for 'alfresco_action'.
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:360 - CacheDecoratorFactory not configured for defaultCache. Skipping for 'alfresco_action'.
     25 Jun 2012 19:40:07 DEBUG Cache:1183 - Initialised cache: alfresco
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:331 - CacheDecoratorFactory not configured. Skipping for 'alfresco'.
     25 Jun 2012 19:40:07 DEBUG ConfigurationHelper:360 - CacheDecoratorFactory not configured for defaultCache. Skipping for 'alfresco'.
     25 Jun 2012 19:40:07 DEBUG DefaultListableBeanFactory:458 - Finished creating instance of bean 'cacheManager'


Any clue? Something seems to be wrong with my configuration.

Thanks for your time<br />Andrea
grenfro

neo

Joined: 06/25/2012 09:35:52
Messages: 8
Offline

Hello giandrea,
These messages are at debug level and thus are not errors. Basically they are saying that you have not enabled certain features that EhCache offers.

--Glenn
giandrea

neo

Joined: 06/25/2012 11:39:11
Messages: 5
Offline

Hi Glenn,

thanks for your reply. My point is, how can I enable the caching? It's not working and I don't understand if it's something misconfigured.

Thanks,
Andrea
steve

ophanim

Joined: 05/24/2006 14:22:53
Messages: 619
Offline

I'll let someone who knows spring annotations help you get through the issues of configuring it but I thought I would point out that instead of using count based tuning (save the last 10 or 100 method invocations) you'd probably get better performance if you used bytes based tuning (use 100m of heap for caching).

http://terracotta.org/products/enterprise-ehcache/automatic-resource-control

http://ehcache.org/documentation/configuration/cache-size

Want to post to this forum? Join the Terracotta Community
giandrea

neo

Joined: 06/25/2012 11:39:11
Messages: 5
Offline

Thanks,

the problem is that I'm expecting something like that in my log:

DEBUG [com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor]: Generated key '167334053963' for invocation: ReflectiveMethodInvocation: public abstract java.util.Collection com.goyello.esa.storage.MessageStorage.findAllMessages(); target is of class [com.goyello.esa.storage.MemoryMessageStorage] DEBUG [com.goyello.esa.storage.MemoryMessageStorage]: == got all messages, size=5

but, my annotated method it's called every time. Cache is not working....
edalquis

journeyman

Joined: 02/10/2010 10:44:27
Messages: 11
Offline

Hello, one of the authors of the annotations package here. A few questions:

For your method:

@Cacheable(value="alfresco")
public EMContents getContents(RestTemplate restTemplate, String ticket, String webScriptUrl, String em_name)

1. Is this method defined by an interface
2. If yes for 1 are you calling the method via that interface from other spring beans
3. You probably don't want the restTemplate being used as part of the cache key. Take a look at http://ehcache-spring-annotations.googlecode.com/svn/site/current/apidocs/com/googlecode/ehcache/annotations/PartialCacheKey.html

You can annotate the three string parameters with @PartialCacheKey so that the RestTemplate parameter is ignored for key generation.
giandrea

neo

Joined: 06/25/2012 11:39:11
Messages: 5
Offline

Hi,

1) no, it's not an interface

2) I changed the method to

@Cacheable(value="alfresco")
public EMContents getContents(String em_name)

but still not working. From junit class I'm calling this method five times but it's not caching anything...
edalquis

journeyman

Joined: 02/10/2010 10:44:27
Messages: 11
Offline

Your method needs to be defined by an interface and clients all must use the interface to make the call. The library uses spring's dynamic proxy support which creates a wrapper around the annotated bean that implements all of the interfaces the bean implements. That wrapper is then what is injected into dependent beans.
giandrea

neo

Joined: 06/25/2012 11:39:11
Messages: 5
Offline

I read on a blog that Annotation has to be added to the method implementation of the interface, is it correct?

Is there another way to use Spring annotation cache without use interface?

edalquis

journeyman

Joined: 02/10/2010 10:44:27
Messages: 11
Offline

The annotation can go on either the interface or the concrete class. Once the JSR107 annotations are final there will be support for Spring's CGLIB class rewriting proxy support which doesn't require an interface but until then an interface is required (and recommended for pretty much every spring annotation that results in a proxy)
shisan

neo

Joined: 05/23/2014 15:36:28
Messages: 2
Offline

Hi giandrea ,
I am also facing same problem that you had.
Are you able to solve the problem ?
If you , can you please tell me how you solve the problem.

Thanks a lot
Shibaji
shisan

neo

Joined: 05/23/2014 15:36:28
Messages: 2
Offline

Hi giandrea ,
I am also facing same problem that you had.
Are you able to solve the problem ?
If you , can you please tell me how you solve the problem.

Thanks a lot
Shibaji
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team