spring using CGLIB proxy even when class implements interface

流过昼夜 提交于 2019-12-08 09:19:50

问题


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?

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.

回答1:


Answering for the sake of other (rare) folks who might do the same mistake.

The aspect setup for spring AOP wasn't correct and was in fact trying to target almost all the classes in the context, which is why EhCache started causing problems as there were more than one CacheManager instances (because of CGLIB proxies as CacheManager doesn't implement an interface)



来源:https://stackoverflow.com/questions/12299236/spring-using-cglib-proxy-even-when-class-implements-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!