1 2 Previous Next 15 Replies Latest reply on Jan 27, 2006 11:22 AM by anupama oruganti

    Stuck configuring TreeCacheAOP - am I missing something?


      Now that I've got the front end caching done using Treecache (piece of cake), I've been fighting with TreeCacheAop to get it to work right. I've followed all the exampled in the docs:

      I've created a jboss-aop.xml ,

       <prepare expr="field(* $instanceof{com.sojournermobile.util.testdata.Rectangle}->*)" />

      but that didn't work on its own. Even though I was using the special class loader and had the META-INF stuff in the classpath (confirmed by doing a getResource() on that file and it came up properly). I can't find a way to see why its not loading my jboss-aop.xml from scratch without precompiling my classes

      So I changed the jboss-aop.xml to instrument everything in a particular package (which is where I store all these data objects now):

       <prepare expr="field(* $instanceof{com.sojournermobile.util.testdata.*}->*)" />

      I've precompiled classes using aopc

       <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="module.classpath"/>
       <target name="aopc" depends="compile" description="Precompile aop class">
       <aopc compilerclasspathref="module.classpath" verbose="true">
       <classpath path="${build}"/>
       <src path="${build}"/>
       <include name="**/*.class"/>
       <aoppath path="/projects/utils/aop/META-INF/jboss-aop.xml"/>

      I've set up precompilation using ant (which actually doesn't seem to be instrumenting my test class in the same manner it wasn't before:

      [trying to transform] com.sojournermobile.util.testdata.Rectangle
      [debug] is advisable method: getX
      [debug] does getX match field(* $instanceof{com.sojournermobile.util.testdata.*}->*): false
      [debug] is advisable method: setX
      [debug] does setX match field(* $instanceof{com.sojournermobile.util.testdata.*}->*): false
      [debug] was com.sojournermobile.util.testdata.Rectangle converted: true

      package com.sojournermobile.util.testdata;
      import org.apache.log4j.*;
       * @@org.jboss.cache.aop.AopMarker
      public class Rectangle
       public static Logger logger = Logger.getLogger("Rectangle");
       private int x;
       private int y;
       private int width;
       private int height;
       private long commitTime;
       public int getX()
       return x;
       public void setX(int x)
       this.x = x;

      No matter what I try to do, I have an issue putting this object into the cache:

      java.lang.IllegalArgumentException: TreeCacheAop.putObject(): Object type is neither aspectized nor Serializable. Object class name is com.sojournermobile.util.Rectangle
      at org.jboss.cache.aop.AopUtil.checkObjectType(AopUtil.java:90)
      at org.jboss.cache.aop.TreeCacheAopDelegate._putObject(TreeCacheAopDelegate.java:146)
      at org.jboss.cache.aop.TreeCacheAop._putObject(TreeCacheAop.java:376)
      at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:255)
      at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:226)
      at com.sojournermobile.util.server.jndi.DirectoryServiceProviderImpl.main(DirectoryServiceProviderImpl.java:110)

      I've gone through the docs a few times now over the past few days and I don't know what's up. Looking at the AOP results suggests that its not preparing the fields and this is my best bet as to what is going wrong, but after having gone through the JbossAOP stuff and the TreeCacheAOP docs several times it looks like I'm doing the right thing.

      I've got to be missing something but I just don't see it.

        • 1. Re: Stuck configuring TreeCacheAOP - am I missing something?

          The ditro comes with a build.xml and couple of aop examples (in junit tests). Why don't you try them out first, e.g., build.sh run.aop.batch or run.aopc.batch. It has target for aopc and annoc as well.

          Let me know what is missing so I can enhance the doc.


          • 2. Re: Stuck configuring TreeCacheAOP - am I missing something?

            Well, I found a surprise sitting in your build path

            <?xml version="1.0" encoding="UTF-8"?>
             <!-- This is declaration file for annotation. We are using JDK1.4 now,
             so an annotationc pre-compiler is needed for JBossAop.
             See build.xml target annoc for details.
             Idea is user will then need only to annotate like:
             in his POJO. There will be no need of jboss-aop.xml from user's side.
             Only extra step is annotation compiling. And in JDK1.5, this step
             will not be needed since the implicit annotation support.
             For example, see either Address or Person.
             <!-- If a POJO has AopMarker annotation, it will be asepctized. -->
             <prepare expr="field(* @org.jboss.cache.aop.AopMarker->*)" />
             Supports inheritance and polymorphism. It can either be a concrete class
             or an interface. All sub-classes or interface implementors will be instrumeneted.
             <prepare expr="field(* $instanceof{@org.jboss.cache.aop.InstanceOfAopMarker}->*)" />

            Is this the correct way to deal with realizing classes or is the approach outlined in the documentation the correct way as the docs take an entirely different approach.

            • 3. Re: Stuck configuring TreeCacheAOP - am I missing something?

              Well after several days I give. TreeCacheAOP is just impossible for me to get set up given the information available so I'll have to overlook it for now. Hopefully the feedback below will help update the documentation for the next guy:

              1) Documentation does a LOT of theory up front and never takes a simple non-bean case as an isolated case of making this architecture work. This makes it impossible to know what all the pieces are and whether or not the process is working. There needs to be a clear, clean -
              a) here is a class
              b) here is a jboss-aop.xml
              c) here is what you need to put in a build script if you on JDK1.4 or 1.5, etc.
              d) here is a simple TreeCacheAop instantiation with a simple treecache.xml that uses local replication
              e) here is what you can do to troubleshoot if it doesn't work (for example I know mine is likely related to JbossAOP since its saying that non of my methods match the signature, but damned if I know what to do about it)

              The docs commit the ultimate sin - no simple HelloWorld level example so you can make sure everything compiles and runs. Without this, you just have a level of complexity from multiple vendor products interacting. The regular TreeCache docs are fine. Page 3 (or section 4) puts up a simple case and explains what's going on in isolation. I can take that code, compile it, and run it and see what's going on.

              2) Don't pay simple lip service to annotation, precompilation configuration. You'll have to learn JBossAOP and configuration to even begin to understand TreeCacheAOP and how it operates when a simple explanation of how the ant tasks work is sufficient.

              3) If I need a special classpath put that in the configuration section as one ot the steps.

              4) The whole documentation should evolve as a series of lessons, not a description of features in action. One shouldn't be at the back of the documentation before you actually get something that at least resembles a lesson/setup

              5) If you're going to use magic locations (META-INF/jboss-aop.xml) then you need to log when you didn't find stuff in those locations or if you did. My first pass through the docs say "put the jboss-aop.xml file in this location". Cool, okay its not working. Is it finding the file? Is it not liking the file? Is it not liking my OSX environment? What's wrong with it - what should I expect to see if its actually working.

              I'd love to write a How-To guide to getting this thing set-up. I've done it before for JBoss (I wrote chunks of Jboss docs years ago) and would do it again, but unless you actually understand the system and how it works - the documentation here is just not useful unless you're modifying the toy examples that the documentation and source tree provide. If I have to go digging through unit tests to figure out how stuff works - something is wrong.

              After going through TreeCacheAop for a few days I have a clear understanding of how it works, and actually understand how I could implement it myself if needed by breaking up the object hierarchy into treepaths in a TreeCache and intercepting the get/set field access and mapping it to methods which update the cache. Its actually a very cool approach - if you can get it to work.

              • 4. Re: Stuck configuring TreeCacheAOP - am I missing something?

                Hi, I am sorry that it is not working out for you. Your suggestions are valuable to me. How about you drop me an email (benwang at jboss dot com)? I will work with you to see where the gaps are. I am sure this will benefit others as well. I do have the plan to revamp the documentation in 1.2.4 release.

                Just curious. Have you gone through the tutorial for TreeCacheAop? I thought it has a very good example of getting people started.



                • 5. Re: Stuck configuring TreeCacheAOP - am I missing something?
                  Jussi Pyörre Newbie

                  I'm stuck with the same problem as gregorypierce while trying to deploy my .ear file into default configuration of JBoss AS 4.0.3RC1 with latest EJB 3 support (EJB-3.0_RC3) on Win XP.

                  I have done the following steps:

                  1) Created a class that should be cached (and jarred it into my .ear),
                  2) added annotationc into ant script (and I made sure that it is actually modifying the bytecode of the class to be put into TreeCacheAop),
                  3) added the provided jboss-aop.xml (from TreeCacheAop examples) to META-INF of my .ear file,
                  4) changed "EnableLoadtimeWeaving" to "true" in jboss-aop-jdk50.deployer/META-INF/jboss-service.xml of my JBoss AS deploy directory
                  5) copied pluggable-instrumentor.jar into JBoss AS bin directory
                  6) modified run.bat: "set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% -javaagent:pluggable-instrumentor.jar", and finally
                  7) executed run.bat

                  However, TreeCacheAop is still telling me that "Object type is neither aspectized nor Serializable" when I call "putObject". It seems to me that jboss-aop-jdk50.deployer is somehow not noticing that there is a class that should be load-time weaved.

                  Any advices?

                  • 6. Re: Stuck configuring TreeCacheAOP - am I missing something?

                    Can you do the pre-compiled mode instead? E.g., using aopc first. This way, we don't depend on the load time weaving.


                    • 7. Re: Stuck configuring TreeCacheAOP - am I missing something?
                      Jussi Pyörre Newbie

                      I finally managed to do the load-time weaving. Everything else was OK, but in jboss-service.xml in jboss-aop-jdk50.deployer I hadn't changed

                      <mbean code="org.jboss.aop.deployment.AspectManagerService" ...>"


                      <mbean code="org.jboss.aop.deployment.AspectManagerServiceJDK5" ...>"

                      as I was using the -javaagent:pluggable-instrumentor.jar.

                      This should have been obvious thing to do (if you read the comment in the beginning of jboss-service.xml), but somehow I managed to miss it when changing the LoadtimeWeaving to true.

                      One reason for missing might be the fact that instructions are fragmented around your web-site quite badly (some are in AOP documentation, some in JBossCache documentation etc.). So when I changed the LoadtimeWeaving to true, I just did that, nothing else (so I actually missed the comment in the beginning of the 'jboss-service.xml'). When I later found out that the command line switch '-javaagent:pluggable-instrumentor.jar' should be added, there was no explicit mentioning about the MBean settings at that place (see http://docs.jboss.com/aop/1.3/aspect-framework/reference/en/html/running.html, 10.3.3).

                      If you just copy the 'jboss-aop-jdk50.deployer' to deploy and change the LoadtimeWeaving to true, ofcourse nothing happens... So, I suggest you add to the documentation in "http://docs.jboss.com/aop/1.3/aspect-framework/reference/en/html/running.html",
                      section "10.3.3. JBoss 4.x and JDK 5" an explicit mentioning that "AspectManagerService" must be also changed to "AspectManagerServiceJDK5" (it is already in the example XML snippet, but it's extremely easy to miss that).

                      I know, this is more like an AOP-issue, but I just have to unburden my mind somewhere, as I spent tens of hours on this issue... :)

                      • 8. Re: Stuck configuring TreeCacheAOP - am I missing something?

                        Ok, thanks for the suggestion. I will let Kabir know about it.


                        • 9. Re: Stuck configuring TreeCacheAOP - am I missing something?
                          Alexander Konakov Newbie

                          I've got some problems with pre-compiled classes.

                          JBoss 4.0.3 SP1 and JDK5


                          <?xml version="1.0" encoding="UTF-8"?>

                          1. aopc ant task works fine - for example, for class Owner (that implements interface Identifiable) with member "email" it creates classes Owner$email_Get.class and Owner$email_Set.class (Owner is EJB3 POJO).
                          2. I deploy EAR with ejb3-archive containing all theese classes to JBoss.
                          2. TreeCacheAOP deployed as a servise works fine as cache - I can put objects to it and get them from it using putObject and getObject


                          1. create owner
                          2. owner.setEmail("email1")
                          3. put owner to cache
                          4. owner.setEmail("email2")
                          5. get owner from cache and... owner.getEmail returns me old value - "email1".

                          What's wrong? I can give you any other information about my software configuration if needed.

                          • 10. Re: Stuck configuring TreeCacheAOP - am I missing something?

                            Some basic troubleshooting steps are probably the best.

                            1) Can you try out the example that comes with the distro (in standalone mode)? If it works,

                            2) Can you try out your example in standalone mode to make sure it works first?

                            3) You will probably need to turn on log tracing to see if the field (email) gets intercepted or not, for example.


                            • 11. Re: Stuck configuring TreeCacheAOP - am I missing something?
                              anupama oruganti Newbie

                              Hi Guys,

                              I saw tutorial for JBoss Tree Cache AOP, I personally thought it's more of theoretical. I need tutorial which will give me simple example of caching String using JBoss TreeCacheAOP, can you guys please direct me to proper one I did search but I found tons of them .

                              I really appreciate your help in making me spin the wheel.

                              Thanks alot,

                              • 12. Re: Stuck configuring TreeCacheAOP - am I missing something?
                                Brian Stansberry Master

                                Why do you want to TreeCacheAop to cache strings? It's immutable and serializable -- there is no benefit. TreeCache is fine for this.

                                If you want to do it:

                                cache.putObject(someFqn, myString);

                                • 13. Re: Stuck configuring TreeCacheAOP - am I missing something?
                                  anupama oruganti Newbie


                                  Thanks for ur reply, I heard that JBoss Tree Cache has some limitations as can't maintain relationships, objects have to be serialized etc but TreeCacheAOP won't have all these since we will be using POJO. so that's why I wanted to use JBoss TreeCacheAOP(POJO Cache) to save some of startup data, can you please direct me to any online tututorial which will help me.

                                  Thanks alot,

                                  1 2 Previous Next