java - spring cache - Null key returned for cache operation -


i have been working spring cache abstraction , ehcache.i'm using @cacheable annotation on target method so:

@component public class dataservice {     @cacheable(value="moviefindcache", key="#name")     public string findbydirector(string name) {         return "hello";     } } 

this junit test:

public class servicetest extends abstractjunit4springcontexttests{      @resource     private dataservice dataservice;      @test     public void test_service() {         system.err.println(dataservice.findbydirector("hello"));     } } 

this not working fine when debug junit test. throws illegalargumentexception follows:

java.lang.illegalargumentexception: null key returned cache operation (maybe using named params on classes without debug info?) cacheableoperation[public java.lang.string com.eliteams.quick4j.web.service.exceldataservice.getcardata()] caches=[moviefindcache] | key='#name' | condition='' | unless='' @ org.springframework.util.assert.notnull(assert.java:112) @ org.springframework.cache.interceptor.cacheaspectsupport.generatekey(cacheaspectsupport.java:315) @ org.springframework.cache.interceptor.cacheaspectsupport.collectputrequests(cacheaspectsupport.java:265) 

i have following config:

applicationcontext.xml:

<cache:annotation-driven cache-manager="cachemanager"/> <bean id="ehcachemanagerfactory" class="org.springframework.cache.ehcache.ehcachemanagerfactorybean"       p:configlocation="classpath:ehcache.xml" p:shared="true"/> <bean id="cachemanager" class="org.springframework.cache.ehcache.ehcachecachemanager"       p:cachemanager-ref="ehcachemanagerfactory"/> 

ehcache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      xsi:nonamespaceschemalocation="http://ehcache.org/ehcache.xsd"      updatecheck="true"      monitoring="autodetect"      dynamicconfig="true">  <diskstore path="java.io.tmpdir" />  <cache name="moviefindcache"        maxentrieslocalheap="10000"        maxentrieslocaldisk="1000"        eternal="false"        diskspoolbuffersizemb="20"        timetoidleseconds="300" timetoliveseconds="600"        memorystoreevictionpolicy="lfu"        transactionalmode="off">     <persistence strategy="localtempswap" /> </cache> 

note: if don't specify "key" in @cacheable annotations, works.

is there forgot specify? config? annotations?

the message of illegalargumentexception pretty explicit. following table in spring documentation indicates available using argument names.

and relevant javac options documented. want -g ones in context.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -