Spring LTW Problem

#1

Hello!

I use ObjectDB with Spring. Today i tried to swich from AspectJ compile time weaving to load time weaving. (To get Jrebel working properly) So i added 

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/WaggonTrackerWebinterface">
    <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
    useSystemClassLoaderAsParent="false" />
</Context>

To my context.xml and

<context:load-time-weaver />

to my spring configuration.

Now Spring oviously tries to weave every class that get's loaded. The problem arises when the ObjectDB Enhancer tries to weave some GWT class of wich some dependencies are not on the classpath:

java.lang.ClassNotFoundException: com.google.gwt.user.client.ui.HasWidgets
at java.lang.ClassLoader.findClass(ClassLoader.java:522)
at com.objectdb.o.ACL.loadClass(ACL.java:131)
at com.objectdb.o.BCL.loadClass(BCL.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at com.objectdb.o.ACL.d(ACL.java:155)
at com.objectdb.o.BCL.loadClass(BCL.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at com.objectdb.o.ACL.d(ACL.java:155)
at com.objectdb.o.BCL.loadClass(BCL.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:390)
at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:371)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:300)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3089)
at java.lang.Class.getAnnotation(Class.java:3048)
at com.objectdb.o.JEW.aI(JEW.java:169)
at com.objectdb.JEnhancerAgent.transform(JEnhancerAgent.java:153)
at org.springframework.orm.jpa.persistenceunit.ClassFileTransformerAdapter.transform(ClassFileTransformerAdapter.java:56)
at org.springframework.instrument.classloading.WeavingTransformer.transformIfNecessary(WeavingTransformer.java:95)
at org.springframework.instrument.classloading.WeavingTransformer.transformIfNecessary(WeavingTransformer.java:78)
at org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader.findResourceInternal(TomcatInstrumentableClassLoader.java:118)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2755)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
at org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(DefaultInstanceManager.java:338)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:145)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:127)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:836)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1782)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

If i don't want AspectJ to weave some class i can restrict it in aop.xml. Maybe it would be a good idea to add something similar to ObjectDB. I don't even need LTW for ObjectDB because i enhance the classes at compile time.

Any suggestions?

Ralph

#2

The ObjectDB Enhancer agent enhances only classes that are annotated with JPA/JDO/ObjectDB annotations. However, since annotations are checked using the Java reflection API - the check itself involves class loading.

The stack trace indicates that an attempt to check annotations of some class leads to a failure due to a missing class in the classpath.

Maybe future versions of ObjectDB should check annotations by reading the class file format directly without using reflection and loading classes into the JVM. This should bring more flexibility. In the current version, the workaround is to make the entire closure of application classes available in the classpath.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

Putting gwt-user.jar on the Classpath ist not an option because it includes some classes that conflict with tomcat. I think a quick fix for your code would be to catch the ClassNotFound Exception and emmit an error message instead. So spring can continue to the AspectJ weaver and my webapp would work fine.

#4

Build 2.3.7_03 includes an attempt to apply your suggestion of catching these exceptions.

Warning messages will be logged.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login