Announcement Announcement Module
No announcement yet.
Spring using CGLIB proxy even when the class to be proxies implements an interface Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring using CGLIB proxy even when the class to be proxies implements an interface

    I'm trying to use Spring AOP to intercept methods of my GWT-RPC application (using GWT-Server library, so RPC service doesn't extend RemoteServiceServlet). When I deploy my war to tomcat and start the application, CGLIB fails for some reason. But I don't understand why CGLIB is being used for proxying at the first place. Since my RPC class implements the interface, shouldn't it be using JDK dynamic proxies? Does my interface need to be a spring bean for that?

    Is there anything I need to do to debug this issue? Kindly advise.

    Note: FYI, Spring encounters this exception, but I believe that's a different problem, I'm unable to understand why CGLIB proxy is in the picture.

    Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.ehcache.CacheException-->Another unnamed CacheManager already exists
    in the same VM. Please provide unique names for each CacheManager in the config
    or do one of following:
    1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
    2. Shutdown the earlier cacheManager before creating new one with same name.
    Last edited by Swapnil.Sonawane; Sep 7th, 2012, 08:19 AM. Reason: better formatting

  • #2
    How do you define the AOP pointcut? It looks like it matches a bean of type CacheManager from ehcache. Since the CacheManager class does not implement any interface, cglib is used. And because cglib calls a constructor twice (and you cannot have two cache managers with the same name or unnamed since ehcache 2.5), it results in the exception you have posted.


    • #3
      Post some code and relevant stacktraces as currently there isn't much to go-on.