Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "LTWJboss7"

(The solution)
(Tying it all together)
Line 27: Line 27:
  
 
#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 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 -Dantorcha.install.dir=/tmp/antorcha -Dorg.aspectj.tracing.enabled=false -Dorg.aspectj.tracing.factory=default"'''
+
#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"'''

Revision as of 22:11, 12 May 2012

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

  1. 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
  2. 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

Here you are an step by step guide:

  1. 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.
  2. 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"

Back to the top