view raw
Naftuli Tzvi Kay Naftuli Tzvi Kay - 6 months ago 117
Java Question

ClassLoader does NOT provide an 'addTransformer(ClassFileTransformer)' method

I'm using Spring and AspectJ to do some nice weaving and I just ran into this issue after inserting

into my application context:

Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
at org.springframework.context.weaving.DefaultContextLoadTimeWeaver.setBeanClassLoader(
... 21 common frames omitted

Do I need a custom JVM to run AspectJ?!? I can't ever remember having to do this before.


I can't find any documentation to support it, but I'm fairly certain that the standard JVM doesn't support Spring's style of load-time weaving. Spring's guide to enabling LTW in different environments implies that this is the case in its "Generic Java applications" section.