5 Replies Latest reply on Jun 17, 2004 11:31 AM by ben.wang

    ClassCastException when application jar is deployed

    mfrost

      Hi

      I am able to use the TreeCache in my JBoss cluster - and it works fine until I redeploy any of my application jars.

      At this point I get a ClassCastException .

      Why is the TreeCache stopped and started when any jar is redeployed - even if it has nothing to do with TreeCache??

      If I subsequently try to use the cache from a SLSB I get the following

      java.lang.NoSuchMethodException: org.jboss.cache.TreeCache._put(org.jboss.cache.GlobalTransaction, org.jboss.cache.Fqn, java.lang.Object, java.lang.Object, boolean)

      I must restart all my cluster nodes.

      I am using JBoss 3.2.3

      I include the following
      1. The ClassCastException stacktrace
      2. My TreeCache XML descriptor (replSync-service.xml). Notice I have not specified a cluster config.
      3. My SLSB code snippet

      Anyone else experienced this?

      Many thanks in advance
      mark


      14:00:25,316 INFO [TreeCache] setState(): setting the new state
      14:00:25,332 ERROR [TreeCache] setState(): could not set cache:
      java.lang.ClassCastException
       at org.jboss.cache.TreeCache$MessageListenerAdaptor.setState(TreeCache.java:2469)
       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.passUp(MessageDispatcher.java:470)
       at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:292)
       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:515)
       at org.jgroups.JChannel.up(JChannel.java:860)
       at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:314)
       at org.jgroups.stack.ProtocolStack.receiveUpEvent(ProtocolStack.java:330)
       at org.jgroups.stack.Protocol.passUp(Protocol.java:470)
       at org.jgroups.protocols.pbcast.STATE_TRANSFER.handleStateRsp(STATE_TRANSFER.java:299)
       at org.jgroups.protocols.pbcast.STATE_TRANSFER.up(STATE_TRANSFER.java:119)
       at org.jgroups.stack.UpHandler.run(Protocol.java:55)
      14:00:25,332 INFO [TreeCache] state was retrieved successfully (in 31 milliseconds
      


      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- Sample TreeCache Service Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <server>
      
       <!--<classpath codebase="file:/C:/jboss/jboss-cache/lib" archives="jboss-cache.jar, jgroups.jar"/>-->
       <classpath codebase="file:/C:/jboss/jboss-cache/lib" archives="jboss-cache.jar"/>
      
      
       <!-- ==================================================================== -->
       <!-- Defines TreeCache configuration -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.cache.TreeCache"
       name="jboss.cache:service=TreeCache">
      
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
      
       <!--
       Configure the TransactionManager
       -->
       <!--
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
       -->
      
       <!--
       Isolation level : SERIALIZABLE
       REPEATABLE_READ (default)
       READ_COMMITTED
       READ_UNCOMMITTED
       NONE
       -->
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
      
       <!--
       Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC
       -->
       <attribute name="CacheMode">REPL_SYNC</attribute>
      
       <!--
       Just used for async repl: use a replication queue
       -->
       <attribute name="UseReplQueue">false</attribute>
      
       <!--
       Replication interval for replication queue (in ms)
       -->
       <attribute name="ReplQueueInterval">0</attribute>
      
       <!--
       Max number of elements which trigger replication
       -->
       <attribute name="ReplQueueMaxElements">0</attribute>
      
       <!-- Name of cluster. Needs to be the same for all clusters, in order
       to find each other
       -->
       <attribute name="ClusterName">TreeCache-Cluster</attribute>
      
       <!-- JGroups protocol stack properties. Can also be a URL,
       e.g. file:/home/bela/default.xml
       <attribute name="ClusterProperties"></attribute>
       -->
      
      
       <!--
       Max number of entries in the cache. If this is exceeded, the
       eviction policy will kick some entries out in order to make
       more room
       -->
       <attribute name="MaxCapacity">20000</attribute>
      
       <!--
       Whether or not to fetch state on joining a cluster
       -->
       <attribute name="FetchStateOnStartup">true</attribute>
      
       <!--
       The max amount of time (in milliseconds) we wait until the
       initial state (ie. the contents of the cache) are retrieved from
       existing members in a clustered environment
       -->
       <attribute name="InitialStateRetrievalTimeout">5000</attribute>
      
       <!--
       Number of milliseconds to wait until all responses for a
       synchronous call have been received.
       -->
       <attribute name="SyncReplTimeout">10000</attribute>
      
       <!-- Max number of milliseconds to wait for a lock acquisition -->
       <attribute name="LockAcquisitionTimeout">15000</attribute>
      
       <!-- Max number of milliseconds we hold a lock (not currently
       implemented) -->
       <attribute name="LockLeaseTimeout">60000</attribute>
      
       <!-- Name of the eviction policy class. Not supported now. -->
       <attribute name="EvictionPolicyClass"></attribute>
      
       </mbean>
      
      
       <!-- Uncomment to get a graphical view of the TreeCache MBean above -->
       <!-- <mbean code="org.jboss.cache.TreeCacheView" name="jboss.cache:service=TreeCacheView">-->
       <!-- <depends>jboss.cache:service=TreeCache</depends>-->
       <!-- <attribute name="CacheService">jboss.cache:service=TreeCache</attribute>-->
       <!-- </mbean>-->
      </server>
      



      // find the first instance of an mbean server in the system (there will only be one)...
      List list = MBeanServerFactory.findMBeanServer(null);
      MBeanServer server = (MBeanServer)list.iterator().next();
      ObjectName cacheService = new ObjectName("jboss.cache:service=TreeCache");;
      Object[] args;
      String[] sig;
      
      if (doPut) {
       //put into cache
       args = new Object[] {FQN, key, value};
       sig = new String[] {String.class.getName(),
       Object.class.getName(),
       Object.class.getName()};
      
       server.invoke(cacheService, "put", args, sig);
      
       System.out.println("...put into cache");
      }
      
      //get from cache
      args = new Object[]{FQN, key};
      sig = new String[]{String.class.getName(), Object.class.getName()};
      value = server.invoke(cacheService, "get", args, sig);
      
      System.out.println("from cache value = " + value.toString());
      
      


        • 1. Re: ClassCastException when application jar is deployed
          mfrost

          I also get the following ClassCastException after redeploying any of my application jars in a clustered environment:

          -------------------------------------------------------
          GMS: address is 172.22.10.58:3127
          -------------------------------------------------------
          17:17:03,598 INFO [TreeCache] viewAccepted(): new members: [172.22.10.58:3121,172.22.10.58:3127]
          17:17:03,645 INFO [TreeCache] setState(): setting the new state
          17:17:03,645 ERROR [TreeCache] setState(): could not set cache:java.lang.ClassCastException: cannot assign instance of org.jboss.cache.Fqn to field org.jboss.cache.Node.fqn of type org.jboss.cache.Fqn in instance of org.jboss.cache.Node
           at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1885)
           at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1076)
           at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1851)
           at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
           at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
           at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
           at org.jgroups.util.Util.objectFromByteBuffer(Util.java:39)
           at org.jboss.cache.TreeCache$MessageListenerAdaptor.setState(TreeCache.java:2468)
           at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.passUp(MessageDispatcher.java:470)
           at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:292)
           at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:515)
           at org.jgroups.JChannel.up(JChannel.java:860)
           at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:314)
           at org.jgroups.stack.ProtocolStack.receiveUpEvent(ProtocolStack.java:330)
           at org.jgroups.stack.Protocol.passUp(Protocol.java:470)
           at org.jgroups.protocols.pbcast.STATE_TRANSFER.handleStateRsp(STATE_TRANSFER.java:299)
           at org.jgroups.protocols.pbcast.STATE_TRANSFER.up(STATE_TRANSFER.java:119)
           at org.jgroups.stack.UpHandler.run(Protocol.java:55)
          17:17:03,660 INFO [TreeCache] state was retrieved successfully (in 62 milliseconds
          17:17:03,660 INFO [TreeCache] Started jboss.cache:service=TreeCache
          


          • 2. Re: ClassCastException when application jar is deployed

            Don't see anything obvious right now. Can you try this using the local-service.xml, i.e., LOCAL mode only? Maybe this can further isolate the problem.

            Thanks,

            -Ben

            • 3. Re: ClassCastException when application jar is deployed
              mfrost

              Hi Ben

              I tried your suggestion and deployed local-service.xml to both of my JBoss nodes in my cluster. Obviously replication doesn't take place now BUT re-deploying my application jar does NOT now cause the ClassCastException.

              If I use replSync-service.xml then replication works fine but as soon as I re-deploy my app jar, the ClastCastException returns and the cache is broken until I bounce the node.

              I hope this helps. If you want me to try any other tests please say.

              Should I submit a bug?

              Many thanks

              mark

              • 4. Re: ClassCastException when application jar is deployed
                mfrost

                OK even more weirdness!

                We currently have 2 deployment folders defined in conf\jboss-service.xml. This is so that we can keep the core JBoss configuration XML/jars etc. separate from our own. It looks like:

                 <!-- ==================================================================== -->
                 <!-- Deployment Scanning -->
                 <!-- ==================================================================== -->
                
                 <!-- An mbean for hot deployment/undeployment of archives.
                 -->
                 <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
                 name="jboss.deployment:type=DeploymentScanner,flavor=URL">
                
                 <!-- Uncomment (and comment/remove version below) to enable usage of the
                 DeploymentCache
                 <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache</depends>
                 -->
                 <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
                
                .....
                
                 <attribute name="URLs">
                 deploy/,file:/${uk.co.hemscott.deploy_root}/server/${jboss.server.name}/deploy
                 </attribute>
                


                If the replSync-service.xml file is placed in the second deployment folder (file:/${uk.co.hemscott.deploy_root}/server/${jboss.server.name}/deploy) then redeploying an application jar will cause the ClassCastException.

                If I deploy the replSync-service.xml file directly into the standard JBoss folder (deploy/) then re-deploying an application jar does NOT cause the ClassCastException.

                Could this possibly due to a bug in the DeploymentScanner somehow? However we don't have any other problems with our application being deployed in a separate deploy folder only JBoss Cache it seems??

                Many thanks

                mark

                • 5. Re: ClassCastException when application jar is deployed

                  It is hard to say whether it is a bug in deployer. But it definitely is weird. I will look into it soon.

                  Thanks,

                  -Ben