FoxyBOA
FoxyBOA

Reputation: 5846

AspectJ load-time weaving for signed jars

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.

Upvotes: 7

Views: 1231

Answers (1)

MikhailDudarev
MikhailDudarev

Reputation: 461

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.

Upvotes: 3

Related Questions