问题
Does anybody success in using AspectJ load-time weaving with signed jars?
I got an exception and have no idea how to fix it (tested with AspectJ 1.6.8-16.10):
Exception in thread "main" java.lang.NoClassDefFoundError: com/package/clazz$AjcClosure1
at com.package.test.main(test.java:55)
Caused by: java.lang.ClassNotFoundException: com.package.clazz$AjcClosure1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
Frankly speaking I event not sure if it's technically possible, but I know that similar issue (using dynamically generated java code from signed java classes) was done for Hibernate project (i.e. using Javassist instead of CGLIB). Details are here.
回答1:
The simular problem is described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=328099 and fixed in AspectJ 1.6.12. AspectJ sometimes generates closure classes during weaving and these must be defined with the same protection domain as the jar that gave rise to them. In 1.6.12.M1 this should now work correctly.
来源:https://stackoverflow.com/questions/4122930/aspectj-load-time-weaving-for-signed-jars