7 Replies Latest reply on Nov 7, 2006 12:02 AM by brian.stansberry

    TreeCache replication: No ClassLoaders found and using TreeC

    jyoonyang

      Hi,

      I was getting "No ClassLoaders found" exception during replication when TreeCache is deployed as an MBean and -service.xml is included within my ear. This problem doesn't occur if I keep -service.xml out side the ear and deploy directly into <JBOSS_HOME>/server//deploy directory

      I'm using JBoss 4.0.4.

      Here is my jboss-app.xml

      <jboss-app>
      ...
       <module>
       <service>MyCachTree-service.xml</service>
       </module>
      ...
      


      Here is my ear
      META-INF/
      META-INF/MANIFEST.MF
      mywar.war
      lib/
      lib/classes12.jar
      META-INF/jboss-app.xml
      MyCachTree-service.xml
      META-INF/application.xml
      


      The offending class is inside mywar.war.

      I tried setting up TreeCacheMarshaller. Now the cache is not getting replicated.

      Here is the code registering the region. This class has reference to the cache and does putting and getting to/from cache.
      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName objName = new ObjectName(getTreeCacheName());
      cache = (TreeCacheMBean) MBeanProxy.get(
       TreeCacheMBean.class,
       objName,
       server);
      cache.registerClassLoader("test", this.getClass().getClassLoader());
      cache.activateRegion("test");
      


      MyCachTree-service.xml
      <attribute name="UseMarshalling">true</attribute>
      <attribute name="InactiveOnStartup">true</attribute>
      


      What am I doing wrong?

      Thanks for your help,
      Jennifer

        • 1. Re: TreeCache replication: No ClassLoaders found and using T
          brian.stansberry

          Questions:

          1) Where is the class that calls cache.registerClassLoader() located?

          2) Are you setting up a scoped loader repository in jboss-app.xml?

          3) In jbossweb-tomcat55.sar/META-INF/jboss-service.xml, what are the values for "Java2ClassLoadingCompliance" and "UseJBossWebLoader"?

          4) You say that after you set up marshalling "Now the cache is not getting replicated." Please be more specific -- what is happening?

          • 2. Re: TreeCache replication: No ClassLoaders found and using T
            jyoonyang

             

            1) Where is the class that calls cache.registerClassLoader() located?

            It is in the war. It is a singleton class loaded by Spring. cache.registerClassLoader() is called inside initialization method.

            2) Are you setting up a scoped loader repository in jboss-app.xml?

            I would like to, but for now I have that commented out.

            3) In jbossweb-tomcat55.sar/META-INF/jboss-service.xml, what are the values for "Java2ClassLoadingCompliance" and "UseJBossWebLoader"?

            <attribute name="Java2ClassLoadingCompliance">false</attribute>
            <attribute name="UseJBossWebLoader">false</attribute>
            


            4) You say that after you set up marshalling "Now the cache is not getting replicated." Please be more specific -- what is happening?


            I added an item into "test" in one cache node in the cluster. I try to do a lookup on the other cache node, and it fails. I also was looking from JMX console. I invoked "printDetails". I see the item in one node, but not in the other.

            I have also tried manually putting and item from the JMX console. I don't see this item when I invoke "printDetails" on the other node.

            Another exception. When I invoked remove method from JMX console, I am seeing "javax.management.IntrospectionException: Failed to find PropertyEditor for type: org.jboss.cache.Fqn"

            Thanks much!

            • 3. Re: TreeCache replication: No ClassLoaders found and using T
              jyoonyang

              Errr....

              I found the culprit. When specifying the node to activate and register class loader, you MUST prefix the node name with a forward slash.

              cache.registerClassLoader("/test", this.getClass().getClassLoader());
              cache.activateRegion("/test");
              


              • 4. Re: TreeCache replication: No ClassLoaders found and using T
                jyoonyang

                I declared victory too early, I think.

                I am seeing this in the log.

                2006-11-03 15:58:04,850 ERROR [org.jgroups.blocks.GroupRequest] - exception=java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: No ClassLoader
                s found for: foo.MyBadObject
                


                There is no exception stack trace. I don't know what this means. I am not seeing bad side-effect from this right now (i.e. items in the cache seem to get replicated ok). Why is the error thrown? How can I fix this?

                Thanks

                • 5. Re: TreeCache replication: No ClassLoaders found and using T
                  brian.stansberry

                  Is foo.MyBadObject a custom exception type that you are throwing from a TreeCacheListener callback? The failure you listed is happening as part of the deserialization of the response to the RPC that's used to replicate data. In JBC, responses to replication RPCs are null unless an exception is thrown. AFAIK the only way the response object would be your custom class would be if you are throwing the exception from a TreeCacheListener.

                  • 6. Re: TreeCache replication: No ClassLoaders found and using T
                    jyoonyang

                    No, foo.MyBadObject is the super class of the object getting put/get to the TreeCache.

                    responses to replication RPCs are null unless an exception is thrown. AFAIK the only way the response object would be your custom class would be if you are throwing the exception from a TreeCacheListener.


                    So what would happen if response object is not null (i.e exception). Will the cache rollback the transaction or something? Is there anything I can do to TreeCacheListener to prevent this ERROR?

                    Thanks!

                    • 7. Re: TreeCache replication: No ClassLoaders found and using T
                      brian.stansberry

                      I just realized what's going on -- when you call put(fqn, key, value) or remove(fqn, key, value), when the call replicates, the old value is returned. That's why foo.MyBadObject is included with the response and can't be deserialized.

                      The old value really shouldn't be returned -- it's just discarded. This is fixed in 1.4.1 which should be out in a few weeks -- see http://jira.jboss.com/jira/browse/JBCACHE-766.

                      Luckily for you, when JGroups has trouble deserializing the response, it just logs the error and treats the response as null. IMHO that's a bug, but in this case it works to your benefit, since JBC is expecting a null. A workaround until 1.4.1 is out is to just suppress ERROR logging from the org.jgroups.blocks.GroupRequest category.