title: Why doesn't my @Cachable annotated method cache the result with EHCache?
body: <p>I have an interceptor in Spring, which autowires two different services.
  Both services have methods that are tagged with <code>@Cacheable</code> from the ehcache-spring-annotations project, but with different <code>cacheNames</code>.</p>
  <pre><code>public class MenuInterceptor extends HandlerInterceptorAdapter {
      @Autowired
      private EventService eventService;
  
      @Autowired
      private OrganisationInfoService orgService;
  
      @Override
      public final void postHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler,
                         ModelAndView modelAndView) throws SystemException {
          eventService.getFolderEventsForUser(123);
          orgService.getOrgCustomProfile(&quot;abc&quot;);
  
      }
  
  @Service
  public class EventServiceImpl implements EventService {
      @Override
      @Cacheable(cacheName = &quot;ecomOrders&quot;)
      public Collection&lt;FolderEventBean&gt; getFolderEventsForUser(long loginId) throws SystemException {
  
  
  @Service(&quot;organisationInfoService&quot;)
  public class OrganisationInfoServiceImpl implements OrganisationInfoService {
      @Override
      @Cacheable(cacheName=&quot;orgProfile&quot;)
      public OrgCustomProfileBean getOrgCustomProfile(String orgHierarchyString) throws ServiceException {
  </code></pre>
  <p>When I run my application, one method successfully uses EHCache for the result, while the other does not. The <code>OrganisationInfoSericeImpl.getOrgCustomProfile()</code> caches properly, while the <code>EventServiceImpl.getFolderEvnetsForUser</code> does not. Can someone please tell me why?</p>
  <p>I have tried to use same cache for both services, but still only one of them works.
  I turned on DEBUG for ehcache-spring-annotations, and it registers both methods during startup:</p>
  <blockquote>
  <p>[DEBUG] 08:09:01 () Adding CACHE advised method 'getFolderEventsForUser' with attribute: CacheableAttributeImpl [cache=[ name = ecomOrders status = STATUS_ALIVE eternal = false overflowToDisk = false maxElementsInMemory = 100 maxElementsOnDisk = 0 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 300 timeToIdleSeconds = 0 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners: net.sf.ehcache.statistics.LiveCacheStatisticsWrapper  hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 0 missCountExpired = 0 ], cacheKeyGenerator=HashCodeCacheKeyGenerator [includeMethod=true, includeParameterTypes=true, useReflection=false, checkforCycles=false], entryFactory=null, exceptionCache=null, parameterMask=ParameterMask [mask=[]]] []  at com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl.getMethodAttribute(CacheAttributeSourceImpl.java:174)</p>
  <p>[DEBUG] 08:09:01 () Adding CACHE advised method 'getOrgCustomProfile' with attribute: CacheableAttributeImpl [cache=[ name = orgProfile status = STATUS_ALIVE eternal = false overflowToDisk = false maxElementsInMemory = 200 maxElementsOnDisk = 0 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 86400 timeToIdleSeconds = 0 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners: net.sf.ehcache.statistics.LiveCacheStatisticsWrapper  hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 0 missCountExpired = 0 ], cacheKeyGenerator=HashCodeCacheKeyGenerator [includeMethod=true, includeParameterTypes=true, useReflection=false, checkforCycles=false], entryFactory=null, exceptionCache=null, parameterMask=ParameterMask [mask=[]]] []  at com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl.getMethodAttribute(CacheAttributeSourceImpl.java:174)</p>
  </blockquote>
  <p>When the interceptor calls the autowired services, only one of them caches:</p>
  <blockquote>
  <p>[DEBUG] 08:09:19 (UNIQUE_ID) Generated key '-1668638847278617' for invocation: ReflectiveMethodInvocation: public abstract no.finntech.base.modules.organisation.support.OrgCustomProfileBean no.finntech.service.organisation.OrganisationInfoService.getOrgCustomProfile(java.lang.String) throws no.finntech.service.ServiceException; target is of class [no.finntech.service.organisation.impl.OrganisationInfoServiceImpl] [URI: /finn/minfinn/myitems/list, Remote IP: 127.0.0.1, Referer: , User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2]  at com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor.generateCacheKey(EhCacheInterceptor.java:272)</p>
  </blockquote>
  <p>EDIT:
  I should probably mention that the two services are defined in different maven modules.</p>