Results 1 to 3 of 3

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

  1. #1

    Default 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 at 08:19 AM. Reason: better formatting

  2. #2
    Join Date
    Sep 2012
    Location
    Czech Republic
    Posts
    39

    Default

    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. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Post some code and relevant stacktraces as currently there isn't much to go-on.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •