6 Replies Latest reply on Sep 1, 2005 7:35 AM by kabirkhan

    problem running injboss example

    sharman

      Hi,

      I am new to jboss-aop and trying to run the example injboss. I have followed previous queries in this forum regarding this problem and followed the steps mentioned in those, but still not able to make it run.

      I am using windows XP, j2sdk 1.4.2_07, jboss app server 4.0.3RC1, jboss aop 1.3.1. I have followed the steps in the documentation for installling jboss aop with jboss. I copied the jboss-aop.deployer to the JBOSS_HOME/server/default/deploy directory. Copied the jdk14-pluggable-instrumentor.jar and jboss-classloader-transformer.jar to the JBOSS_HOME/bin directory. Modified the run.bat to edit this line

      set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% -Xbootclasspath/p:jboss-classloader-transformer.jar;jdk14-pluggable-instrumentor.jar

      and modified the JBOSS_HOME/server/default/deploy/jboss-aop.deployer/META-INF/jboss-service.xml file

      attribute name="EnableLoadtimeWeaving" as true
      attribute name="Include">org.jboss.test,org.jboss.injbossaop

      After following all these steps, when I run injboss example the Interceptor is not called. I am getting the output as


      17:10:28,768 INFO [STDOUT] **** ExampleValue empty Constructor
      17:10:28,768 INFO [STDOUT] **** ExampleValue.getMessage()
      17:10:35,017 INFO [STDOUT] **** BasicExampleServlet.service()
      17:10:35,017 INFO [STDOUT] **** ExampleValue String Constructor
      17:10:35,017 INFO [STDOUT] **** ExampleValue.getMessage()

      Kindly tell me what am I missing.

      Thanx,
      NS

        • 1. Re: problem running injboss example
          kabirkhan

          It works for me on windows....


          * Unzip jboss-4.0.3RC2 distribution
          * Unzip jboss-aop_1.3.1 distribution

          Setup jboss for loadtime weaving
          --------------------------------------
          * Delete jboss-4.0.3RC2/server/default/jboss-aop.deployer
          * Copy jboss-aop_1.3.1/jboss-40-install to jboss-4.0.3RC2/server/default/ (So that we have jboss-4.0.3RC2/server/default/jboss-aop.deployer)
          * Modify jboss-4.0.3RC2/server/default/jboss-aop.deployer/META-INF/jboss-service.xml as follows

          <server>
          
           <!-- The code for the service is different for the different run scenarios
           *** JBoss 4.0
           * JDK 1.4 - org.jboss.aop.deployment.AspectManagerService
           * JDK 5 (not using -javaagent switch) - org.jboss.aop.deployment.AspectManagerService
           * JDK 5 (using -javaagent switch) - org.jboss.aop.deployment.AspectManagerServiceJDK5
           * BEA JRockit 1.4.2 - org.jboss.aop.deployment.AspectManagerService
           *** JBoss 3.2
           * JDK 1.4 - org.jboss.aop.deployment.AspectManagerService32
           * JDK 5 (not using -javaagent switch) - org.jboss.aop.deployment.AspectManagerService32
           * JDK 5 (using -javaagent switch) - org.jboss.aop.deployment.AspectManagerService32JDK5
           * BEA JRockit 1.4.2 - org.jboss.aop.deployment.AspectManagerService32
           -->
           <mbean code="org.jboss.aop.deployment.AspectManagerService"
           name="jboss.aop:service=AspectManager">
           <attribute name="EnableLoadtimeWeaving">true</attribute>
           <!-- only relevant when EnableLoadtimeWeaving is true.
           When transformer is on, every loaded class gets
           transformed. If AOP can't find the class, then it
           throws an exception. Sometimes, classes may not have
           all the classes they reference. So, the Suppressing
           is needed. (i.e. Jboss cache in the default configuration -->
           <attribute name="SuppressTransformationErrors">true</attribute>
           <attribute name="Prune">true</attribute>
           <attribute name="Include">org.jboss.test, org.jboss.injbossaop</attribute>
           <attribute name="Exclude">org.jboss.</attribute>
           <attribute name="Optimized">true</attribute>
           <attribute name="Verbose">false</attribute>
           </mbean>
          
           <mbean code="org.jboss.aop.deployment.AspectDeployer"
           name="jboss.aop:service=AspectDeployer">
           </mbean>
          
          </server>
          


          * Generate jboss-classloader-transformer.jar and copy it to jboss-4.0.3RC2/bin
          * Copy jboss-aop_1.3.1/lib/jdk14-pluggable-instrumentor.jar to jboss-4.0.3RC2/bin
          * Modify run.bat on Windows (note the semicolon separating the bootclasspath entries)
          set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% -Xbootclasspath/p:jboss-classloader-transformer.jar;jdk14-pluggable-instrumentor.jar

          *Start JBoss
          cd jboss-4.0.3RC2/bin
          run


          setup injboss example
          --------------------------
          * modify jboss-aop_1.3.1/docs/aspect-framework/examples/injboss/
           <!-- Set jboss.dir property to root of your JBoss distribution -->
           <property name="jboss.dir" value="c:/temp/jboss-4.0.3RC2"/>
           <!--
           Set jboss.server.config property to either default or all.
           if you set this to default, JBoss should be started with
           run -c default
           if you set this to all, JBoss should be started with
           run -c all
           -->
           <property name="jboss.server.config" value="default" />
          

          * Run one of the targets, for example
          cd jboss-aop_1.3.1/docs/aspect-framework/examples/injboss/
          ant deploy-ear



          • 2. Re: problem running injboss example
            sharman

            Thanx Kabir,

            The compile time (ct) deployment are working fine for me, but the problem is with the runtime deployment...Those are still not working. Is there any extra step I need to make runtime deployment work?

            NS

            • 3. Re: problem running injboss example
              sharman

              When I run "ant deploy-ear", it say

              file

              Classes have not been aop'ed - run JBoss with enable transformations = true
              Deploying ear with a standard contents and a standalone jboss-aop.xml
              


              How can I enable transformations = true?/??? and can this be the problem that loadtime weaving is not working??

              NS

              • 4. Re: problem running injboss example
                kabirkhan

                It works for me using Windows. I will try it out on cygwin to see if there is a problem there (I don't have linux installed)

                • 5. Re: problem running injboss example
                  kabirkhan

                   

                  "SharmaN" wrote:
                  When I run "ant deploy-ear", it say

                  file
                  Classes have not been aop'ed - run JBoss with enable transformations = true
                  Deploying ear with a standard contents and a standalone jboss-aop.xml
                  


                  How can I enable transformations = true?/??? and can this be the problem that loadtime weaving is not working??

                  NS


                  No, this just means that classes have not been transformed at compile time, so loadtime weaving is needed.






                  • 6. Re: problem running injboss example
                    kabirkhan

                    It all works for me.....

                    Here are my jars:

                    Kabir@KabirDell /c/temp/jboss-4.0.3RC2
                    $ ls -al bin/*.jar
                    -rwxrwxrwx+ 1 Kabir None 8650 Sep 1 12:28 bin/jboss-classloader-transformer.jar
                    -rwxrwxrwx+ 1 Kabir None 2331 Sep 1 12:41 bin/jdk14-pluggable-instrumentor.jar
                    -rwxrwxrwx+ 1 Kabir None 37863 Aug 13 14:07 bin/run.jar
                    -rwxrwxrwx+ 1 Kabir None 17295 Aug 13 14:07 bin/shutdown.jar
                    -rwxrwxrwx+ 1 Kabir None 43291 Aug 13 14:07 bin/twiddle.jar
                    



                    My run.bat:
                    ...
                    rem Setup JBoss specific properties
                    set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% -Xbootclasspath/p:jboss-classloader-transformer.jar;jdk14-pluggable-instrumentor.jar
                    set JBOSS_HOME=%DIRNAME%\..
                    ...
                    



                    My run.sh (Since I am using cygwin I need to use a semicolon ";" separating jboss-classloader-transformer.jar and jdk14-pluggable-instrumentor.jar, on proper linux/unix I guess you'd use a colon ":")
                    ...
                    # Setup JBoss sepecific properties
                    JAVA_OPTS="$JAVA_OPTS -Dprogram.name=$PROGNAME -Xbootclasspath/p:jboss-classloader-transformer.jar;jdk14-pluggable-instrumentor.jar"
                    ...
                    


                    My jboss-4.0.3RC2/server/default/deploy/jboss-aop.deployer/META-INF/jboss-service.xml file:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <server>
                     <mbean code="org.jboss.aop.deployment.AspectManagerService"
                     name="jboss.aop:service=AspectManager">
                     <attribute name="EnableLoadtimeWeaving">true</attribute>
                     <!-- only relevant when EnableLoadtimeWeaving is true.
                     When transformer is on, every loaded class gets
                     transformed. If AOP can't find the class, then it
                     throws an exception. Sometimes, classes may not have
                     all the classes they reference. So, the Suppressing
                     is needed. (i.e. Jboss cache in the default configuration -->
                     <attribute name="SuppressTransformationErrors">true</attribute>
                     <attribute name="Prune">true</attribute>
                     <attribute name="Include">org.jboss.test, org.jboss.injbossaop</attribute>
                     <attribute name="Exclude">org.jboss.</attribute>
                     <attribute name="Optimized">true</attribute>
                     <attribute name="Verbose">false</attribute>
                     </mbean>
                     <mbean code="org.jboss.aop.deployment.AspectDeployer"
                     name="jboss.aop:service=AspectDeployer">
                     </mbean>
                    </server>
                    


                    I can either run this from a DOS command-line
                    run.bat
                    


                    or, this from a cygwin shell
                    run.sh
                    


                    If you want to run any other configuration of jboss, by running "run -c all", you need to modify the jboss-4.0.3RC2/server/all/deploy/jboss-aop.deployer/META-INF/jboss-service.xml file.

                    ------------------------------------

                    If you want to make sure that the pluggable instrumentor is getting picked up, you could compile the following and replace JDK14TransformerManager in jdk14-pluggable-instrumentor.jar:

                    package org.jboss.aop.hook;
                    
                    public class JDK14TransformerManager
                    {
                    
                     public static JDK14Transformer transformer;
                    
                     public JDK14TransformerManager()
                     {
                     }
                    
                     public static byte[] transform(ClassLoader loader, String className, byte classBytes[])
                     {
                     System.out.println("Class: " + className);
                     if(transformer == null)
                     {
                     System.out.println("no transformer");
                     return null;
                     }
                     if(isNonAdvisableClassName(className))
                     {
                     System.out.println("Non advisable");
                     return null;
                     } else
                     {
                     System.out.println("transforming");
                     return transformer.transform(loader, className, classBytes);
                     }
                     }
                    
                     public static boolean isNonAdvisableClassName(String classname)
                     {
                     return classname.startsWith("org.jboss.aop") ||
                    classname.endsWith("$aop") ||
                    classname.startsWith("javassist") ||
                    classname.startsWith("org.jboss.util.") ||
                    classname.startsWith("gnu.trove.") ||
                    classname.startsWith("EDU.oswego.cs.dl.util.concurrent.") ||
                    classname.startsWith("org.apache.crimson") ||
                    classname.startsWith("org.apache.xalan") ||
                    classname.startsWith("org.apache.xml") ||
                    classname.startsWith("org.apache.xpath") || classname.startsWith("org.ietf.") || classname.startsWith("org.omg.") ||
                    classname.startsWith("org.w3c.") || classname.startsWith("org.xml.sax.") || classname.startsWith("sunw.") || classname.startsWith("sun.") ||
                    classname.startsWith("java.") || classname.startsWith("javax.") ||
                    classname.startsWith("com.sun.") || classname.startsWith("junit") ||
                    classname.startsWith("jrockit.") || classname.startsWith("com.bea.vm.");
                     }
                    }
                    
                    


                    You should see output like:
                    Kabir@KabirDell /c/temp/jboss-4.0.3RC2/bin
                    $ run.sh
                    =========================================================================
                    
                     JBoss Bootstrap Environment
                    
                     JBOSS_HOME: C:\temp\jboss-4.0.3RC2
                    
                     JAVA: /c/Java/jdk/j2sdk1.4.2_08/bin/java
                    
                     JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh -Xbootclasspath/p:jboss-classloader-transformer.jar;jdk14-pluggable-i
                    nstrumentor.jar
                    
                     CLASSPATH: C:\temp\jboss-4.0.3RC2\bin\run.jar;C:\Java\jdk\j2sdk1.4.2_08\lib\tools.jar
                    
                    =========================================================================
                    
                    Class: org.jboss.Main
                    no transformer
                    Class: org.jboss.Main$1
                    no transformer
                    Class: gnu.getopt.LongOpt
                    no transformer
                    Class: gnu.getopt.Getopt
                    no transformer
                    Class: org.jboss.system.server.ServerLoader
                    no transformer
                    Class: org.jboss.system.server.NoAnnotationURLClassLoader
                    no transformer
                    Class: org.jboss.system.server.ServerImpl
                    no transformer
                    


                    Note that it will not start transforming until a bit later in the startup process, i.e. once the AOPManager is deployed. If you don't see this output, it means you have got the settings wrong in your run.sh/run.bat wrong.