The annotation @Cacheable is disallowed for this location
3,416 views
Skip to first unread message
sajjanmanju
unread,
Jun 23, 2011, 10:29:17 AM6/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ehcache Spring Annotations
Hi,
I am trying to implement ehCache (general purpose caching) using
spring annotations. But when I type @Cacheable in my class just
before the method, I am getting an error that: "The annotation
@Cacheable is disallowed for this location". I am using Spring 3.0.3
maven2. Any one faced same problem...?? And @Cacheable is supported in
spring 3.0.3 ???
Any help will be appreciated.
Thanks in advance.
Nicholas Blair
unread,
Jun 23, 2011, 10:32:05 AM6/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
@cacheable is only valid on methods. Spring 3.0.x is fine.
Nicholas Blair
unread,
Jun 23, 2011, 10:37:18 AM6/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
I should add that your class must also implement an interface, otherwise the package will not be able to proxy your annotated methods.
Manjunath Sajjan
unread,
Jun 23, 2011, 10:41:48 AM6/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
Ya I have an interface, if i type @cacheable in interface, i am getting same problem.."The annotation
@Cacheable is disallowed for this location"
Of course I am using Spring 3.0.3...
-- -Manjunath Sajjan
Eric Dalquist
unread,
Jun 23, 2011, 11:01:10 AM6/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
Can you share an example of your class and methods with @Cacheable?
Manjunath Sajjan
unread,
Jun 24, 2011, 12:26:23 AM6/24/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
Thanks for your replies...
Here is my code. Also tried giving @Cacheable("RestCallCache") in place of @Cacheable, still getting same error. //My interface
import javax.persistence.Cacheable;
public interface IRestClient { @Cacheable //Geting error at this line
public ResponseEntity<?> callRest(HttpEntity<?> requestEntity, String ServiceUrl, Class<?> Classref); }
//My Class implementation of interface
import javax.persistence.Cacheable; public class RestClient implements IRestClient { @Cacheable //Geting error at this line also
public ResponseEntity<?> callRest(HttpEntity<?> requestEntity, String ServiceUrl, Class<?> Classref) { RestTemplate restTemplate = new RestTemplate(); //some more lines here;implementation details here;
} }
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
Look at your import. You're using the Cacheable annotation that exists in JPA
-Eric
Manjunath Sajjan
unread,
Jun 24, 2011, 9:46:04 AM6/24/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
Thanks Eric for replying.. I resolved that problem. Now I am facing problem in caching.. I followed this link: http://code.google.com/p/ehcache-spring-annotations/wiki/UsingCacheable
But caching is not happening.. my cached method is getting called every time... One more thing is, in Debug message the "Generated key" is different every time I call the cached function. If you have any working example of maven type project, if you can share it would be helpful (as I am new to caching)..
Thanks in advance. -Manju
-- -Manjunath Sajjan
Eric Dalquist
unread,
Jun 24, 2011, 10:23:47 AM6/24/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ehcache-sprin...@googlegroups.com
The default key generator relies on the hashCode method of each method argument. I'd check the HttpEntity impl to see if it's hashCode does what you expect.