Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
LTWJboss7
Introduction
This document is intended to provide a reference for understanding how to successfully activate AspectJ LTW under jBoss 7.X.
The Problem
These are the problems that can occur when trying to activate LTW under JBoss 7:
1. You get an exception like this type and afterwards the server suddenly stops:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.modules.Module.run(Module.java:260)
at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
at org.jboss.logmanager.log4j.BridgeRepositorySelector.<clinit>(BridgeRepositorySelector.java:42)
2. Even if you have been able to make the server startup using some JBoss configuration options as suggested here: https://issues.jboss.org/browse/AS7-1 your aspects are not getting applied where they should.
The solution
- The IllegalStateException is thrown by jBoss7 because there is a bug that limits access to java.util.logging. You can see the acknowledged bug here. There, a partial solution to avoid this problem is suggested, regarding changing the way the loadmanager is loaded, pushing it to the BootClasspath and adding several configuration options. However we suggest deactivating the AspectJ tracing facilities. You can achieve this by adding the next options:
-Dorg.aspectj.tracing.enabled=false -Dorg.aspectj.tracing.factory=default - Due to new JBoss classloader and modularization architecture, classes stored in your javaagent are not visible to the remaining modules, so your aspects will not be found and you will get different types of errors. To let your aspects been found by all your code you have to add the aspectjweaver, and aspects.jar files to the bootclasspath and add the next option to JBoss startup: -Djboss.modules.system.pkgs=org.aspectj,com.yourcompany.aspects.package that makes every class under those packages shared across all the modules in the JBoss system.
Tying it all together
So the steps are:
- Modify the jar containing your aop.xml. Move that aop.xml somewhere inside your package structure, for instance com/company/myaspects/aop.xml and create the jar again as aspects.jar.
- Modify JBoss standalone.cnf file adding these options to the end of it: JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=com.company.myaspects,org.aspectj -Dorg.aspectj.weaver.loadtime.configuration=com/company/myaspects/aop.xml -Xbootclasspath/a:/tmp/aspects.jar:/tmp/aspectjweaver.jar -javaagent:/tmp/aspectjweaver.jar -Dorg.aspectj.tracing.enabled=false -Dorg.aspectj.tracing.factory=default"