13 Replies Latest reply on Nov 15, 2004 6:26 AM by Tomasz Nazar

    Problems with using TreeCacheAop for the first time

    Andrew May Newbie

      Hello,

      I have the same problem with the difference that:

      -JbossCache 1.1
      -standalone without anything else (JBossAS..)
      -adviced all the classes' fields with 'prepare' tag
      -have two different applications: Forum and Bank
      -both uses collections but Bank uses map.values() and a map where values consists of other collections (Lists)

      -Forum applications works OK
      *-Bank throws exception when putting into tree : "..IllegalArgumentException: get/set types differ"

      Any suggestions? Is the problem related to lack of support for these collections' methods?

      Could you be more specific about "overloading a call to a method", please?

      Best regards, Tomasz

        • 1. Re: Problems with using TreeCacheAop for the first time
          Tomasz Nazar Newbie

           

          "bwang00" wrote:
          For setter method, you can't ovelroad it like:

          void setName(String name);
          void setName(Object obj);

          This will be fixed in the upcoming 1.2 release in November. In addition, the collection classes api will be enhanced as well.

          -Ben


          Sorry, but had to let you know..

          I have two classes. None of them overloads any method. One implements interface. Every getter/settter exists for every private field (except static ones).

          Still have: "IAE: get/set types differ" when putting object to cache.. :(

          JBossCache 1.1

          :(

          I have sth like this:
          Root:
           List _children;
           addChild(Child);
           findChild(String name);
          
          ChildImpl implements Child
           ....
          
          Child
           getName()
           ...
          



          • 2. Re: Problems with using TreeCacheAop for the first time
            Paul Vallender Newbie

             

            "bwang00" wrote:
            For setter method, you can't ovelroad it like:

            void setName(String name);
            void setName(Object obj);

            This will be fixed in the upcoming 1.2 release in November. In addition, the collection classes api will be enhanced as well.

            -Ben


            Sorry, but had to let you know..

            I have two classes. None of them overloads any method. One implements interface. Every getter/settter exists for every private field (except static ones).

            Still have: "IAE: get/set types differ" when putting object to cache.. :(

            JBossCache 1.1

            :(

            I have sth like this:
            Root:
             List _children;
             addChild(Child);
             findChild(String name);
            
            ChildImpl implements Child
             ....
            
            Child
             getName()
             ...
            



            • 3. Re: Problems with using TreeCacheAop for the first time
              Andrew May Newbie

              Here's an update. I ran AopC over my classes using the same jboss-aop.xml and it aspectized them. When I added the same objects to the TreeCacheAop it now appears to be trying to create a tree of the objects that compose my CounterLicense, but it fails with this error:

              java.lang.IllegalArgumentException: get/set types differ
               at org.jboss.cache.aop.CachedAttribute.setType(CachedAttribute.java:41)
               at org.jboss.cache.aop.CachedType.analyze(CachedType.java:163)
               at org.jboss.cache.aop.CachedType.<init>(CachedType.java:55)
              


              I've not confirmed this with a debugger, but from reading the CachedType code I'm fairly sure that this is because one of the component object has an overloaded set method (e.g. setValue(Object) and setValue(String)), and the second method with the same attribute name causes this error.

              Is there any way to work around this (other than changing the classes)? Does the TreeCacheAop only detect changes via get/set methods or does it examine modifications to fields directly? If so, can I configure the prepare such that it ignores the methods on only considers the fields? Or am I just talking garbage?

              -Andrew

              • 4. Re: Problems with using TreeCacheAop for the first time
                Ben Wang Master

                Andrew,

                To asnwer your questions.

                1) The exception you reported looks like a bug to me. I will fix it soon.

                2) To get around that, you can't overload the method call now.

                3) In jboss-aop.xml, you will need to prepare all of classes with field interception. That's the most important part.

                Thanks,

                -Ben

                • 5. Re: Problems with using TreeCacheAop for the first time
                  Tomasz Nazar Newbie

                  Hello,

                  I have the same problem with the difference that:

                  -JbossCache 1.1
                  -standalone without anything else (JBossAS..)
                  -adviced all the classes' fields with 'prepare' tag
                  -have two different applications: Forum and Bank
                  -both uses collections but Bank uses map.values() and a map where values consists of other collections (Lists)

                  -Forum applications works OK
                  *-Bank throws exception when putting into tree : "..IllegalArgumentException: get/set types differ"

                  Any suggestions? Is the problem related to lack of support for these collections' methods?

                  Could you be more specific about "overloading a call to a method", please?

                  Best regards, Tomasz

                  • 6. Re: Problems with using TreeCacheAop for the first time
                    Ben Wang Master

                    For setter method, you can't ovelroad it like:

                    void setName(String name);
                    void setName(Object obj);

                    This will be fixed in the upcoming 1.2 release in November. In addition, the collection classes api will be enhanced as well.

                    -Ben

                    • 7. Re: Problems with using TreeCacheAop for the first time
                      Andrew May Newbie

                      Ben, thanks for your replies.

                      I managed to work around my problem with the overloaded method by not preparing the class that was causing the problem (it's just a value in a Map, and I'll just pretend it's immutable whilst I'm testing!).

                      So, I did manage to get my CounterLicense put into the cache, and it gets replicated OK, but changes the a Map object my class holds don't seem to be getting replicated - when I call a buisiness method on the CounterLicense class it does a put on the Map. Whilst the in-memory representation of Map on the server it was created contains the additional entry, I don't see it when I "printDetails" on the TreeCacheAop MBean on either of the servers I have clustered.

                      In the tutorial it mentions that you have to get the collection from the cache in order to get the dynamic proxy that has replaced the Map. So when I'm putting my CounterLicense into the cache I tried overriding it's reference to the Map with what I get from the cache:

                      treeCache.putObject(new Fqn("/licenses/lic123"), license);
                      license.setPropertyMap((Map)treeCache.getObject(new Fqn("/licenses/lic123/properties")));
                      


                      but this causes a (not very useful) stack overflow:

                       ...
                       at javassist.ClassPool.toClass(ClassPool.java:713)
                       at org.jboss.aop.deployment.JBossClassPool.toClass(JBossClassPool.java:50)
                       at javassist.ClassPool.toClass(ClassPool.java:713)
                       at org.jboss.aop.deployment.JBossClassPool.toClass(JBossClassPool.java:50)
                      
                       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:207)
                       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
                       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
                      


                      So I'm assuming that wasn't the right thing to do!

                      However, looking at printDetails in the JMX console, I'm not sure whether it's a proxy that's bound into the cache in place of the Map:

                      /licenses
                      /lic123
                      jboss:internal:class: class com.ingenta.ics.license.CounterLicense
                      AOPInstance: org.jboss.cache.aop.AOPInstance@f93ee4
                      
                      ... (other fields)...
                      
                      /properties
                      jboss:internal:class: class java.util.HashMap
                      

                      My environment is JBoss-4.0.0 using the included jboss-aop and jboss-cache versions, but with an upgraded version of javassist.jar.

                      Is this something that would be addressed by the upcoming Collection enhancements in the 1.2 release?

                      Regards,

                      -Andrew

                      • 8. Re: Problems with using TreeCacheAop for the first time
                        Ben Wang Master

                        Just the get/set methods can't be overloaded now. Constructor should be ok.

                        -Ben

                        • 9. Re: Problems with using TreeCacheAop for the first time
                          Tomasz Nazar Newbie

                           

                          "bwang00" wrote:
                          For setter method, you can't ovelroad it like:

                          void setName(String name);
                          void setName(Object obj);

                          This will be fixed in the upcoming 1.2 release in November. In addition, the collection classes api will be enhanced as well.

                          -Ben


                          Sorry, but had to let you know..

                          I have two classes. None of them overloads any method. One implements interface. Every getter/settter exists for every private field (except static ones).

                          Still have: "IAE: get/set types differ" when putting object to cache.. :(

                          JBossCache 1.1

                          :(

                          I have sth like this:
                          Root:
                           List _children;
                           addChild(Child);
                           findChild(String name);
                          
                          ChildImpl implements Child
                           ....
                          
                          Child
                           getName()
                           ...
                          



                          • 10. Re: Problems with using TreeCacheAop for the first time
                            Ben Wang Master

                            Can you create a JUnit test case and submit it here or email me (ben.wang@jboss.com)? I'll take a look.

                            Thanks,

                            -Ben

                            • 11. Re: Problems with using TreeCacheAop for the first time
                              Tomasz Nazar Newbie

                               

                              "bwang00" wrote:
                              Can you create a JUnit test case and submit it here or email me (ben.wang@jboss.com)? I'll take a look.

                              Thanks,

                              -Ben


                              Ok. Prepared sources and sent to you. When you'll find the_thing, let us know and show where the problem lies.

                              Thanks,
                              Tomasz Nazar

                              • 12. Re: Problems with using TreeCacheAop for the first time
                                Ben Wang Master

                                Tomasz,

                                I have tried your test case, it has worked in the latest jboss-head tree. Would you mind to try it out since I have made many enhancement, specially in TreeCacheAop part. You can test drive it and give me feedback as well. :-)

                                BTW, you will need to make log transient so it is not put in the cache.

                                Thanks,

                                -Ben

                                • 13. Re: Problems with using TreeCacheAop for the first time
                                  Tomasz Nazar Newbie


                                  Hi!

                                  Thanks for tip about "transient log". That was the problem in JbossCache 1.1

                                  I won't check CVS version for now. I'll wait till 2.0. And btw, when will it be? ~end of november?

                                  Rgrds, Tomasz