4 Replies Latest reply on Oct 5, 2005 4:01 PM by adamw

    Aspect available for all applications - configuration, jrock

    adamw

      Hello,
      I'm trying to make an ascpect available for all deployed applications (more precisely, I'm trying to make a custom "@Inject" annotation). I have managed to make it work, but I think that the configuration is complicated. Here's what I did:
      - use sun's jdk 5
      - jboss-aop-jdk50-deployer/META-INF/jboss-service.xml:
      - changed the code attribute to AspectManagerServiceJDK50
      - enabled loadtime weaving
      - jbossweb-tomcat55.sar/META-INF:
      - set UseJBossWebLoader to true
      - run.conf:
      - added the -javaagent switch to JAVA_OPTS
      - copied pluggable-instrumentor.jar to the bin directory

      Now, my question is: can I ommit any of this configuration, is it all necessary? Can I make it in an easier way? :).

      My second question is about jrockit - is it supported right now to work with AOP and java 5? I found a jrockit-pluggable-instrumentor.jar in the lib-50 directory, but I suppose it's meant for java 1.4? Anyway, I tried copying it and substituting pluggable-instrumentor.jar with it, and it didn't work. Do I need any additional configuration?

      Thank you for any replies,
      Adam

        • 1. Re: Aspect available for all applications - configuration, j
          kabirkhan

          1) If you use compile-time weaving you can cut down on the config necessary

          2) As far as I can remember, the jrockit transformer is supposed to work with both JDK versions. Did you get any errors when trying it out, and did you follow the steps in the reference guide?

          • 2. Re: Aspect available for all applications - configuration, j
            adamw

            1. Yes, I thought about that, just run-time weaving is much cooler and doesn't require to compile everything using aopc :).

            2. Is there any additional configuration for jrockit needed? I copied jrockit-pluggable-instrumetor.jar into the bin directory, and added:

            JAVA_OPTS="$JAVA_OPTS -javaagent:jrockit-pluggable-instrumentor.jar"

            to run.conf. When I run, I get the following error:

            java.lang.ClassNotFoundException: org.jboss.aop.standalone.Agent
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(Ljava.lang.String;Z)Ljava.lang.Class;(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(Ljava.lang.String;)Ljava.lang.Class;(Unknown Source)
            at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:133)
            The application has requested the JVM to exit with an fatal error from JNI. Error message:
            processing of -javaagent failed.

            If I switch to pluggable-instrumentor.jar and sun's jdk it works.

            • 3. Re: Aspect available for all applications - configuration, j
              kabirkhan

              I'm afraid the jrockit jvm takes another set of switches

              Standalone:

              $ java -cp=<classpath as described above> -Djboss.aop.path=<path to jboss-aop.xml> \
               -Xmanagement:class=org.jboss.aop.hook.JRockitClassPreProcessor com.blah.MyMainClass
              


              In JBoss:
              modify run.sh:
              # Setup JBoss sepecific properties
              JAVA_OPTS="$JAVA_OPTS -Dprogram.name=$PROGNAME \
               -Xmanagement:class=org.jboss.aop.hook.JRockitPluggableClassPreProcessor"
              JBOSS_CLASSPATH="$JBOSS_CLASSPATH:jrockit-pluggable-instrumentor.jar"
              


              jboss-service.xml
              <mbean code="org.jboss.aop.deployment.AspectManagerService"
               name="jboss.aop:service=AspectManager">
              ...
              </mbean>
              
              


              • 4. Re: Aspect available for all applications - configuration, j
                adamw

                Hello,
                thank you very much for the answers, it worked. However, I also, quite accidentaly, ran the "sun jdk" setup (that is, code="org.jboss.aop.deployment.AspectManagerServiceJDK5", -javaagent=pluggable-instrumentor.jar) with jrockit and it works! I even restarted the computer to check but still, everything is ok, with both jdks :)
                The first time I tried it two days ago I got some error with libinstrument.so. Maybe I did something different then too.

                --
                Adam