8 Replies Latest reply on Mar 17, 2005 12:16 PM by Kaarthik Sivashanmugam

    AOPC question on the inner <src> tag

    Mathew Thomas Newbie

      Documentation for aopc tag describes the src tag as:

      src - Which files to be transformed. Either a directory containing the files to be instrumented, or an ant fileset containing which files should be precompiled. In the example above, we specified a directory so all our classes are passed in to the precompiler.

      How can i specify an ant fileset so that i may selectively aop"ize" only certain classes? Without it my aop target is taking too long to execute and eventually runs out of memory since there are too many files.

      I just want to know how based on the documentation i can specify a fileset. All my attempts to do that seem to fail.

        • 1. Re: AOPC question on the inner <src> tag
          Tomasz Nazar Newbie

          As depends on first, all you need is only to compile needed plain _Java_ files - including aspects you want. Put then, every compiled *.class file into your "build" directory and run on that directory.

          Here snippets from my build.xml:

          
          <target name="compile" depends="common:read_params"
           description="Java sources compilation">
           <javac
           destdir="${build.classes.dir}"
           debug="on"
           debuglevel="lines, vars, source"
           deprecation="on"
           depend="on"
           nowarn="on"
           optimize="off"
           >
          
           <include name="**/*.java" />
           <src path="${src.main.dir}" />
           <src path="${src.aspects.dir}/persistence" />
           <src path="${src.aspects.dir}/transactions" />
          
           <classpath refid="compile_classpath"/>
           </javac>
           </target>
          
           <!--
           | Weave all the sources with JBossAOP compiler
           -->
           <target name="aopc" depends="common:read_params">
           <aopc compilerclasspathref="run_classpath" classpathref="run_classpath"
           verbose="false">
           <classpath path="run_classpath" />
           <src path="${build.classes.dir}" />
           <aoppath path="${etc.dir}/jboss-aop.xml" />
           </aopc>
           </target>
          


          Of course you know, you may also use regular expressions inside jboss-aop.xml. This might help.
          And how many of those aspects, source files do you have anyway?
          Or/and how much memory do you have?


          Regards,
          Tomasz

          • 2. Re: AOPC question on the inner <src> tag
            Mathew Thomas Newbie

            Thx for the response. The sample you have is the same i have in my build.



            Problem is by the time in my build process aopc runs....the above classes folder probably has around 3000 or so compiled classes.

            My aspect definition in the -aop.xml file is against all classes that have a pattern of *BO.class (of course written in the manner expected by aop). We have probably around 200-250 classes that end with *BO. These are our business objects. I cannot change the current build structure since thats pretty much written in stone (or not managed by me). If you run aopc against so many classes (with verbose turned ON) you will see that it tries to match every .class to the patterns defined in the -aop.xml file. And at some point dies outofmemory. I am still surprised with this implementation. Since we use weblogic the build dir even contains all weblogic precompiled classes.

            - Now the workaround for me is to copy the *BO classes in my aop build first to a temp classes folder...aspect against that classes folder and then move them back to the main folder...will work but not the most desirable approach.

            • 3. Re: AOPC question on the inner <src> tag
              Kabir Khan Master

              Hi,

              From our testsuite:

               <aopc compilerclasspathref="aop.task.classpath">
               <classpath refid="aop.task.classpath"/>
               <classpath path="${build.tests.classes}"/>
               <src path="${build.tests.classes}"/>
               <include name="org/jboss/test/aop/basic/**"/>
               <aoppath path="${source.res}/test/basic/jboss-aop.xml"/>
               </aopc>
              
              


              You should be able to add multiple include elements, and they can contain patterns. So this should work:
               <include name="com/package1/package2/**/*BO.class"/>
              


              Please let me know if this helps.

              • 4. Re: AOPC question on the inner <src> tag
                Mathew Thomas Newbie

                Thanks for the tip. That works.

                I would never have guessed that include would be a child element of aopc itself. From the doc i thought i had to code in a ant fileset element.

                • 5. Re: AOPC question on the inner <src> tag
                  Kabir Khan Master

                  I'll fix the docs. Thanks for bringing it up :-)

                  • 6. Re: AOPC question on the inner <src> tag
                    Kaarthik Sivashanmugam Newbie

                    I am using maven. Doing "maven java:compile" results in the error message shown below.

                    maven.xml snippet

                     <postGoal name="java:compile">
                     <echo>Running AopC</echo>
                     <attainGoal name="aopCompile"/>
                     </postGoal>
                    
                     <goal name="aopCompile">
                     <taskdef name="aopc" classname="org.jboss.aop.ant.AopC">
                     <classpath id="aop.jboss.classpath">
                     <pathelement path="${pom.getDependencyClasspath()}"/>
                     <pathelement location="${maven.build.dir}/classes"/>
                     </classpath>
                     </taskdef>
                    
                     <aopc verbose="true">
                     <src path="${maven.build.dir}/classes"/>
                     <include name="class_loc/**"/>
                     <aoppath path="${maven.build.dir}/src/conf/jboss-aop.xml"/>
                     </aopc>
                     </goal>
                    

                    error message
                    java:compile:
                     [echo] Compiling to C:\EclipseWorkspace\<project_dir>/target/classes
                     [echo] Running AopC
                    Tag library requested that is not present: 'maven' in plugin: 'null'
                    
                    BUILD FAILED
                    File...... C:\EclipseWorkspace\build\<project_dir>\maven.xml
                    Element... aopc
                    Line...... 70
                    Column.... 24
                    Error running aopc compiler:
                    Total time: 2 seconds
                    Finished at: Thu Mar 17 09:59:32 EST 2005
                    


                    Any ideas, how I can get a more detailed error message ?



                    • 7. Re: AOPC question on the inner <src> tag
                      Kaarthik Sivashanmugam Newbie

                      well...actually, I can get the stack trace...but I dont know how to fix it....the stack trace is

                      BUILD FAILED
                      Error running aopc compiler:
                       at org.jboss.aop.ant.AopC.execute(AopC.java:278)
                       at org.apache.tools.ant.Task.perform(Task.java:341)
                       at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
                       at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
                       at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
                       at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTa
                      g.java:79)
                       at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.perfor
                      mAction(MavenGoalTag.java:110)
                       at com.werken.werkz.Goal.fire(Goal.java:639)
                       at com.werken.werkz.Goal.attain(Goal.java:575)
                       at com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
                       at org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttai
                      nGoalTag.java:127)
                       at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
                       at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
                       at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
                       at com.werken.werkz.jelly.PostGoalTag$1.firePostGoal(PostGoalTag.java:87
                      )
                       at com.werken.werkz.Goal.firePostGoalCallbacks(Goal.java:710)
                       at com.werken.werkz.Goal.fire(Goal.java:654)
                       at com.werken.werkz.Goal.attain(Goal.java:575)
                       at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:
                      671)
                       at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
                       at org.apache.maven.cli.App.doMain(App.java:488)
                       at org.apache.maven.cli.App.main(App.java:1239)
                       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
                      java:39)
                       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                      sorImpl.java:25)
                       at java.lang.reflect.Method.invoke(Method.java:585)
                       at com.werken.forehead.Forehead.run(Forehead.java:551)
                       at com.werken.forehead.Forehead.main(Forehead.java:581)
                      Caused by: java.lang.NullPointerException
                       at org.jboss.aop.ant.AopC.execute(AopC.java:238)
                       ... 27 more
                      --- Nested Exception ---
                      java.lang.NullPointerException
                       at org.jboss.aop.ant.AopC.execute(AopC.java:238)
                       at org.apache.tools.ant.Task.perform(Task.java:341)
                       at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
                       at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
                       at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
                       at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTa
                      g.java:79)
                       at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.perfor
                      mAction(MavenGoalTag.java:110)
                       at com.werken.werkz.Goal.fire(Goal.java:639)
                       at com.werken.werkz.Goal.attain(Goal.java:575)
                       at com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
                       at org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttai
                      nGoalTag.java:127)
                       at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
                       at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
                       at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
                       at com.werken.werkz.jelly.PostGoalTag$1.firePostGoal(PostGoalTag.java:87
                      )
                       at com.werken.werkz.Goal.firePostGoalCallbacks(Goal.java:710)
                       at com.werken.werkz.Goal.fire(Goal.java:654)
                       at com.werken.werkz.Goal.attain(Goal.java:575)
                       at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:
                      671)
                       at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
                       at org.apache.maven.cli.App.doMain(App.java:488)
                       at org.apache.maven.cli.App.main(App.java:1239)
                       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
                      java:39)
                       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                      sorImpl.java:25)
                       at java.lang.reflect.Method.invoke(Method.java:585)
                       at com.werken.forehead.Forehead.run(Forehead.java:551)
                       at com.werken.forehead.Forehead.main(Forehead.java:581)
                      


                      Thoughts ?

                      • 8. Re: AOPC question on the inner <src> tag
                        Kaarthik Sivashanmugam Newbie

                        final update...I copied

                         <classpath id="aop.jboss.classpath">
                         <pathelement path="${pom.getDependencyClasspath()}"/>
                         <pathelement location="${maven.build.dir}/classes"/>
                         </classpath>
                        

                        under and it WORKED.