5 Replies Latest reply on Mar 16, 2005 8:42 PM by Ben Wang

    TreeCacheAop can't add an object of a class which extends Ar

    James Adams Novice

      I am having trouble getting TreeCacheAop to add objects of a class which extends ArrayList. According to the FAQ this is possible:

      TreeCacheAop supports classes extending from List, Set, and Map without users to declare them "aspectized". It is done via a dynamic proxy.


      Simple objects such as Strings are being added and replicated with no errors, so the TreeCacheAop appears to be configured correctly.

      The class in question extends ArrayList. In my test code I create a new object of this class and try to add it to a TreeCacheAop using putObject(). At this point JBossCache bombs and throws an CacheException. This happens using three separate scenarios with jboss-aop.xml: 1) no jboss-aop.xml at all, 2) using a jboss-aop.xml with an "advisable" entry for my class as specified in the example jboss-aop.xml from the jboss-cache distribution, and 3) using a jboss-aop.xml with a "prepare" entry for my class as described in the TreeCacheAop document. So it appears that the jboss-aop.xml file is having no effect on this behavior, or at least the error is the same for the three configurations I've tried.

      Here is the exception stack trace:

      11:15:53,681 ERROR [TreeCacheTester] Unable to add a new UserMessages object for user ID JADAMS1
      org.jboss.cache.CacheException: failure creating proxy; - nested throwable: (org.jboss.util.NestedRuntimeException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages; - nested throwable: (java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages))
       at org.jboss.cache.aop.TreeCacheAop._putObject(TreeCacheAop.java:346)
       at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:130)
       at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:108)
       at com.harborsideplus.treecachetest.mbean.TreeCacheTester.getUserMessages(TreeCacheTester.java:165)
       at com.harborsideplus.treecachetest.mbean.TreeCacheTester.addUserMessage(TreeCacheTester.java:225)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:236)
       at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:202)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:241)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:79)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:61)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
       at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
       at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.util.NestedRuntimeException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages; - nested throwable: (java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages)
       at org.jboss.cache.aop.CollectionInterceptorUtil.getMethodMap(CollectionInterceptorUtil.java:52)
       at org.jboss.cache.aop.CachedListInterceptor.<init>(CachedListInterceptor.java:39)
       at org.jboss.cache.aop.TreeCacheAop._putObject(TreeCacheAop.java:344)
       ... 53 more
      Caused by: java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages
       at java.lang.Class.newInstance0(Class.java:335)
       at java.lang.Class.newInstance(Class.java:303)
       at org.jboss.aop.proxy.ClassProxyFactory.newInstance(ClassProxyFactory.java:59)
       at org.jboss.cache.aop.CollectionInterceptorUtil.getMethodMap(CollectionInterceptorUtil.java:50)
       ... 55 more
      11:15:53,722 ERROR [TreeCacheTester] Unable to add a message to the UserMessagesManager for the user with ID JADAMS1
      javax.management.MBeanException: Unable to add a new UserMessages object for user ID JADAMS1
       at com.harborsideplus.treecachetest.mbean.TreeCacheTester.getUserMessages(TreeCacheTester.java:171)
       at com.harborsideplus.treecachetest.mbean.TreeCacheTester.addUserMessage(TreeCacheTester.java:225)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:236)
       at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:202)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:241)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:79)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:61)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
       at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
       at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.cache.CacheException: failure creating proxy; - nested throwable: (org.jboss.util.NestedRuntimeException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages; - nested throwable: (java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages))
       at org.jboss.cache.aop.TreeCacheAop._putObject(TreeCacheAop.java:346)
       at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:130)
       at org.jboss.cache.aop.TreeCacheAop.putObject(TreeCacheAop.java:108)
       at com.harborsideplus.treecachetest.mbean.TreeCacheTester.getUserMessages(TreeCacheTester.java:165)
       ... 50 more
      Caused by: org.jboss.util.NestedRuntimeException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages; - nested throwable: (java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages)
       at org.jboss.cache.aop.CollectionInterceptorUtil.getMethodMap(CollectionInterceptorUtil.java:52)
       at org.jboss.cache.aop.CachedListInterceptor.<init>(CachedListInterceptor.java:39)
       at org.jboss.cache.aop.TreeCacheAop._putObject(TreeCacheAop.java:344)
       ... 53 more
      Caused by: java.lang.InstantiationException: org.jboss.aop.proxy$com.harborsideplus.treecachetest.pojo.UserMessages
       at java.lang.Class.newInstance0(Class.java:335)
       at java.lang.Class.newInstance(Class.java:303)
       at org.jboss.aop.proxy.ClassProxyFactory.newInstance(ClassProxyFactory.java:59)
       at org.jboss.cache.aop.CollectionInterceptorUtil.getMethodMap(CollectionInterceptorUtil.java:50)
       ... 55 more
      



      Any insight as to why this is happening and/or how I can work around this will be quite appreciated. Thanks in advance.


      --James

        • 1. Re: TreeCacheAop can't add an object of a class which extend
          Ben Wang Master

          James,

          You should not need to decalre anything (unless your list object is a pojo). I have created a JUnit test to test out the inherit list proxy generation.

          It seems to be working. I have checked in the code under jboss-head/testsuite/src/main/test/cache/test/standAloneAop/CollectionProxyAopTest. Check it out.

          -Ben

          • 2. Re: TreeCacheAop can't add an object of a class which extend
            James Adams Novice

            Thanks Ben. The class is a POJO, in that it extends ArrayList and adds a user ID property. I created this class in order to try to take advantage of the ability to use the caching without "aspectizing" my class, as described in the FAQ, but as you have pointed out this only works if the class is not a POJO. With this in mind I'll go back to using my original class which contains an ArrayList and a String as members and try to properly "aspectize" this class so that it can be fully replicated by the TreeCacheAop.

            Can you reference the definitive documentation which outlines how I should "aspectize" my class? I have found two examples of how this should be done via the jboss-aop.xml file, but neither has worked for me so far. For example in the jboss-cache 1.2 distribution there is a jboss-aop.xml (found in jboss-cache/etc/META-INF) which looks like this:

            <aop>
             <advisable class="org.jboss.test.cache.test.standAloneAop.Address"
             fieldFilter="ALL"
             methodFilter="ALL"
             constructorFilter="ALL"
             />
             <advisable class="org.jboss.test.cache.test.standAloneAop.Person"
             fieldFilter="ALL"
             methodFilter="ALL"
             constructorFilter="ALL"
             />
            </aop>
            


            And in the TreeCacheAop document (http://docs.jboss.org/jbcache/TreeCacheAop.html) it looks like this:
            <aop>
             <prepare expr="field(* $instanceof{org.jboss.test.cache.test.standAloneAop.Address}->*)" />
             <prepare expr="field(* $instanceof{org.jboss.test.cache.test.standAloneAop.Person}->*)" />
            </aop>
            


            Which, if either, of these approaches for jboss-aop.xml is correct? If one or the other is to be used then perhaps I am missing some other piece of the puzzle, as I have tried both with no joy so far.


            --James

            • 3. Re: TreeCacheAop can't add an object of a class which extend
              Ben Wang Master

              Where did you find the first jboss-aop.xml example again? It should be "prepare" since JBossAop beta. The first one has been outdated.

              Best way is to run the the aop examples under distro and take it from there.

              -Ben

              • 4. Re: TreeCacheAop can't add an object of a class which extend
                James Adams Novice

                 

                "ben.wang@jboss.com" wrote:

                I have checked in the code under jboss-head/testsuite/src/main/test/cache/test/standAloneAop/CollectionProxyAopTest. Check it out.
                -Ben


                When I browse the CVS repository here http://cvs.sourceforge.net/viewcvs.py/jboss/ I don't see the file, in fact I don't see anything at all under jboss-head. Is there another way to access this file ?

                As far as using the wrong distribution for examples I think it happened because in the JBossCache tutorial (http://docs.jboss.org/jbcache/Tutorial.html) there is a an instruction to download the stand alone TreeCache code from SourceForge, and to use the configuration files under the jboss-cache/etc directory. This is a bit ambiguous as far as which actual distribution should be downloaded, and so I downloaded JBossCache-1.2.zip which does have the directory and files mentioned. Unfortunately the configuration files are out of date, and contain a bug which prevents replication. Specifically the replSync-service.xml contains an entry in the ClusterConfig attribute, bind_addr="localhost", which prevents synchronous replication from working. This set me back for days, but once I located this bug the replication started working as advertised. The example jboss-aop.xml contains invalid entries, but at least the correct entries are described in another document, and now that I am using these "prepare" entries all is well.

                My suggestion is to modify the tutorial so that it no longer points new users to the wrong distribution for examples, as this will make learning how to use JBossCache much less frustrating. I'm still not clear as to which exact distribution has correct examples, as I don't see a jboss-cache/etc under the JBossAOP distribution. Perhaps there are good examples in the new JBossCache release ?

                In any event I now have my application running with JBossCache using TreeCacheAop. The replication works really well -- kudos to Ben and Bela and to the rest of the team who put this all together.


                --James

                • 5. Re: TreeCacheAop can't add an object of a class which extend
                  Ben Wang Master

                  The module name is jboss-test, I believe. But if you want to run the testsuite, you can check out the whole jboss-head using anonymous cvs.

                  We are in the process getting the tutorial updated. So thanks for the suggestion.

                  However, your bind_addr problem works for most of the machines, actually (it works for mine).

                  Then the jboss-aop.xml in release 1.2.1 is the right one. So I am not sure which one you are referring to exactly?

                  -Ben