3 Replies Latest reply on Nov 1, 2002 7:11 AM by Panagiotis Korros

    ClassCastException after Tomcat restart

    Rune Teigen Newbie

      I am using jboss-3.0.0_tomcat-4.0.3.
      I have a method:
      public int compare(Object obj1, Object obj2)
      {
      TxDetails txd = (TxDetails)obj1;
      ...
      }
      The method is used to sort an array of objects. In this case I know that obj1 is instanceof TxDetails. The object obj1 is retrieved from a session-variable in a JSP. The method works fine when I run the first time after starting Tomcat with no saved session-data (removed session.ser). BUT after redeploying my app to Tomcat, the line above results in a ClassCastException. Something seems to happen to the object after it has been serialized - de-serialized by Tomcat. Is this a know problem?

      (ps. If I let the class TxDetails NOT implement Serializable, I don't get the Exception, but then of course Tomcat is not able to preserve the session when I redeploy the app (it throws an exception on redeploy).)

        • 1. Re: ClassCastException after Tomcat restart
          Rune Teigen Newbie

          After a long examination of the forum, where there are quite a few ClassCastException-problems. I decided to change my build. Previously I built a server.jar and a client.jar. The EJBs were of course deployed from the server.jar, while I put the client.jar in the WEB-INF/lib-catalog of my .war-file. I put the server.jar and the .war into a .ear for deployment. A class might be in both the server.jar and the client.jar, and it seems like this, combined with different ClassLoaders, may have caused the problem.

          When I don't create the client.jar, my problem has disappeared. I haven't quite figured out why the problem arose after hot-deploy, and not before, but I guess it is merely a question of digging. Any comments?

          • 2. Re: ClassCastException after Tomcat restart
            Thomas Hollfelder Newbie

            Hi,

            I encounter the same problem, I have a ejb-jar and a ejb-client.jar in my war-file I add the client-jar and after a redeploy I get a classcastexception (I wonder why because the client-jar hasn't changed). I resolve it via a shutdown of the whole jboss and then delete the folder under catalina/work/localhost/$Context-Root and then restart jboss.
            I haven't found a better way, but it has cost me a day to find out that the classcastexception seems to be not a "real" classcastexception.
            If you have information how to make a real redeploy with the tomcat, please let me know. I also tried to stop just the EmbeddedCatalinaSX, then delete the folder and then restart the EmbeddedCatalinaSX but that didn't work (also redeploy after restart did not work).

            • 3. Re: ClassCastException after Tomcat restart
              Panagiotis Korros Newbie

              I have this problem too.
              It's quite annoying.
              Does anyone has a workaround?