I'm trying to use LTW in Wildfly 10, and running into an interesting quandry with the classloader/module structure. In WF10, class loading is based on modules that have to define explicit dependencies on other modules (similar in concept to Jigsaw classloader I believe).
So in order to launch my EAR with LTW enabled, I need to first define the javaagent as a JAVA_OPTS passed to Wildfly on startup. Which means the aspectjweaver.jar has to be available somewhere.
However, when my application itself loads, the classloader also needs a visibility on the aspectjweaver.jar file. Without it, I get the following error message.
15:13:36,849 ERROR [stderr] (MSC service thread 1-1) [ModuleClassLoader@17d1e6a3] warning define generated class failed -- (NoClassDefFoundError) org/aspectj/runtime/internal/AroundClosure
15:13:36,850 ERROR [stderr] (MSC service thread 1-1) org/aspectj/runtime/internal/AroundClosure
15:13:36,850 ERROR [stderr] (MSC service thread 1-1) java.lang.NoClassDefFoundError: org/aspectj/runtime/internal/AroundClosure
15:13:36,850 ERROR [stderr] (MSC service thread 1-1) at java.lang.ClassLoader.defineClass1(Native Method)
That make sense to me, since by default, the classloader for my application will not have visibility to the container classloader, unless defined explicitly. Plus, I do not have the aspectjweaver.jar bundled in my application.
So I have 2 choices:
1) bundle the ajweaver.jar in my EAR/lib folder
2) add ajweaver.jar as a module in Wildfly and create a dependency on it for my application
What is the recommended approach? In case:
1) I still have to make the jar available to the container for the javaagent weaver to be available to the JVM on container startup.
2) I could potentially have different EARs each with different AJ versions bundled
Am I able to use the javaagent of one version of AJ with a different version of AJ bundled with the EAR?
Does it make more logical sense to have the LTW library (ie: ajweaver.jar) bundled in the container and exposed, or simply wrapped up in the EAR itself?
Or am I just splitting hairs?
Thanks,
Eric