Skip to content

Latest Spring AOP + CGLib caches classes from the same classloader causing CCE in Grails [SPR-4153] #8831

@spring-projects-issues

Description

@spring-projects-issues

Graeme Rocher opened SPR-4153 and commented

In Grails we have a custom class loader that reloads classes when they are changed. Previously Spring's AOP support had no problem with this, but with Spring 2.5 and cglib proxies CGLib, what happens is when we reload a class we get a ClassCastException.

The problem appears to be the Enhancer class in CGLib, it will cache classes based on their originating ClassLoader. This may be fine for Java systems, but with Groovy and Grails we use a reloading capable class loader.

The problem is even bigger because there is no way in Spring to disable caching using the useCache property defined in AbstractClassGenerator.

If there was some way in ProxyFactoryBean and AbstractSingletonProxyFactoryBean to set to disable class caching in CGLib we could get round this. The original issue in the Grails JIRA is:

http://jira.codehaus.org/browse/GRAILS-1771

For the moment my solution is the wrap the classloader in another class loader by passing the class loader as a parent to a child classloader. But this may have other side effects and is generally undesirable.


Affects: 2.5 final

Issue Links:

3 votes, 5 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions