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"

m (Introduction)
(The Problem)
Line 5: Line 5:
 
= The Problem  =
 
= The Problem  =
  
If you have tried to activate LTW under jBoss 7 you will have found unless three problems that prevents it to work.
+
These are the problems that can occur when trying to activate LTW under JBoss 7:
  
 
<br>  
 
<br>  
  
#You get an exception of type and afterwards the server suddenly stops:
+
1. You get an exception like this type and afterwards the server suddenly stops:
<blockquote>Exception in thread "main" java.lang.ExceptionInInitializerError<br> at org.jboss.as.server.Main.main(Main.java:73)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br> at java.lang.reflect.Method.invoke(Method.java:597)<br> at org.jboss.modules.Module.run(Module.java:260)<br> at org.jboss.modules.Main.main(Main.java:291) <br>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")<br> at org.jboss.logmanager.Logger.getLogger(Logger.java:60)<br> at org.jboss.logmanager.log4j.BridgeRepositorySelector.&lt;clinit&gt;(BridgeRepositorySelector.java:42) </blockquote>  
+
<blockquote><tt>Exception in thread "main" java.lang.ExceptionInInitializerError<br> at org.jboss.as.server.Main.main(Main.java:73)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br> at java.lang.reflect.Method.invoke(Method.java:597)<br> at org.jboss.modules.Module.run(Module.java:260)<br> at org.jboss.modules.Main.main(Main.java:291) <br>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")<br> at org.jboss.logmanager.Logger.getLogger(Logger.java:60)<br> at org.jboss.logmanager.log4j.BridgeRepositorySelector.&lt;clinit&gt;(BridgeRepositorySelector.java:42) </tt></blockquote>  
#Even if you have been able to make the server startup using some jBoss configuration options as suggested in the next [https://issues.jboss.org/browse/AS7-1 link]&nbsp;your aspects are not beeing injected where they should.
+
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 https://issues.jboss.org/browse/AS7-1]&nbsp;your aspects are not getting applied where they should.
  
<br>  
+
<br>
  
 
= The solution  =
 
= The solution  =

Revision as of 12:05, 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 prevents any class to the 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 configurations. However we suggest to remove AspectJ tracing facilities and preventing it to use through configuration to avoid it.  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 booclasspath and add the next option to jboss startup: -Djboss.modules.system.pkgs=org.aspectj,com.yourcompany.aspects.pacakage that makes every class under those packages to be shared across all the modules in the jBoss system.


Tighting all together

Here you are an step by step guide:

  1. Modify the jar contanining 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 the next 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"

Back to the top