JBoss.org Community Documentation

10.3.3. Loadtime transformation in JBoss AS Using Sun JDK

JBoss AS has special integration with JDK (from version 5.0 on) to do loadtime transformations. This section explains how to use it.

If you want to do load-time transformations with JBoss 5 and Sun JDK, these are the steps you must take.

  • Set the enableLoadtimeWeaving attribute/property to true. By default, JBoss application server will not do load-time bytecode manipulation of AOP files unless this is set. If suppressTransformationErrors is true failed bytecode transformation will only give an error warning. This flag is needed because sometimes a JBoss deployment will not have all the classes a class references.
  • Copy the pluggable-instrumentor.jar from the lib/ directory of your JBoss AOP distribution to the bin/ directory of your JBoss AOP application server installation.
  • Next edit run.sh or run.bat (depending on what OS you're on) and add the following to the JAVA_OPTS environment variable:
    set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% -javaagent:pluggable-instrumentor.jar
    		            

Note that the class of the AspectManager Service must be org.jboss.aop.deployers.AspectManagerJDK5 on JBoss 5, or org.jboss.aop.deployment.AspectManagerServiceJDK5 as these are what work with the -javaagent weaver.