14 Replies Latest reply on Jun 18, 2003 9:00 AM by kalimero

    ClassCastException

    loshsu

      Following problem occurs on JBoss 3.2.1

      I have developed a 'sar' package to be deployed in a node of a cluster. The package is mainly a client using a clustered stateless session bean, which is deployed in another node. The package looks up the session bean successfully via HA-JNDI and does it's job nicely.

      The problem arises when I try to redeploy an updated package into the original node. I have to restart JBoss so the package can be succefully started up.

      The stack trace is attached.

      Cheers,
      Allen

        • 1. Re: ClassCastException
          loshsu

          Attached file.

          • 2. Re: ClassCastException
            avel

            Try to use in PortableRemoteObject.narrow(ref, Class.forName("...ClusteredStoreActionHome"))

            • 3. Re: ClassCastException
              mferreg

              I also have a problem like this, but I'm not using clustering. Exception is attached.

              I'm working with jboss 3.2.0 with tomcat.

              Any help would be really good, I'm allways loosing my time in redeploying!

              • 4. Re: ClassCastException
                loshsu

                Class.forName is still not helping.
                I also try the same package on the node where the session bean is deployed but such problem doesn't happen at all.

                Cheers,
                Allen

                • 5. Re: ClassCastException
                  slaboure

                  Can you please try to:
                  - get a fresh copy from CVS (module jboss-3.2 from Branch_3_2)
                  - compile it with JDK >= **1.4** (and NOT 1.3)
                  - try again?

                  Thank you. Cheers,


                  sacha

                  • 6. Re: ClassCastException
                    loshsu

                    Finally, I managed to get the new branch from CVS, which is jboss-3.2.2beta after compiling.

                    With no luck, the problem still occurs in this version and the stacktrace looks identical.

                    Cheers,
                    Allen

                    • 7. Re: ClassCastException

                      In the testsuite you will find a utility class.
                      testsuite/src/main/org/jboss/test/util/Debug.java

                      It has a displayClassInfo static method.

                      Use this method to print the class info
                      for the class you pass to the narrow method
                      and object.getClass() of the object returned
                      from HAJNDI

                      Regards,
                      Adrian

                      • 8. Re: ClassCastException
                        slaboure

                        Thank you for the help Dr. Bo ;)

                        • 9. Re: ClassCastException
                          loshsu

                          Got the ClassInfo.

                          Cheers,
                          Allen

                          • 10. Re: ClassCastException

                            Can you check the JBossRMIClassLoader
                            is in run.jar?

                            Your info shows the proxy being cached
                            against jboss-service.xml which is the
                            classloader that loads server/default/lib

                            That is exactly the behaviour I would expect
                            from Sun's implementation of the RMIClassLoader.
                            Since server/default/lib is statically deployed,
                            it will never reload it.

                            The idea behind the JBossRMIClassLoader is
                            that it will cache the proxy against your
                            application's classloader so that when you
                            recycle it during a redeploy, it will be discarded.

                            Maybe the proxy is being unmarshalled when the
                            server/default/lib classloader
                            is set as the thread context classloader?
                            Sacha, does HAJNDI do anything special with
                            the marshalling?

                            Regards,
                            Adrian

                            • 11. Re: ClassCastException
                              slaboure

                              standard RMI serialization, but as HA-JNDI has its code loaded from a /lib JAR, maybe it makes trouble. shouldn't though as they all use the UCL at the end.

                              • 12. Re: ClassCastException
                                loshsu

                                Finally, this thread comes to an end.
                                That's nice to have somebody answering when you got questions.

                                After setting a system property java.rmi.server.RMIClassLoaderSpi=org.jboss.system.JBossRMIClassLoader, the redeployment runs nicely without any ClassCastException.


                                Cheers,
                                Allen

                                • 13. Re: ClassCastException
                                  slaboure

                                  Good to know!

                                  • 14. Re: ClassCastException at redeployment
                                    kalimero

                                    I have to post it here - this thread has the topic - not really clustering specific - but it will not work in a clustered environtment, too *gg*

                                    Problem with Redeployment of EJB. All files (Source & Binaries & build script are attached)

                                    We are running jboss-3.2.1_tomcat-4.1.24 (default config)

                                    JBoss: Release ID: JBoss [WonderLand] 3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)
                                    Java: Java version: 1.4.1_02,Sun Microsystems Inc.


                                    The demo is a simple servlet that makes a lookup on a Statless Session Bean. (see source)

                                    First run it works fine, if we redeploy the ejb part the class cast exception will occure.

                                    We don't want to redeploy the war file (in this case it work fine...)

                                    1.) use ant to rebuild.
                                    2.) prebuild versions are available in the /deploy folder
                                    - test_servlet.war
                                    - test_ejb.jar

                                    3.) start JBoss and deploy test_servlet.war and test_ejb.jar
                                    4.) http://localhost:8080/test_servlet/
                                    The following output will occour:
                                    08:51:58,006 ERROR [STDERR] ClassLoader lookup TestHome ----> org.jboss.mx.loading.UnifiedClassLoader3@99176f{ url=file:/C:/Programme/jboss/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/test_ejb.jar/54.test_ejb.jar ,addedOrder=35}
                                    08:51:58,006 ERROR [STDERR] ClassLoader TestHome in Servlet ----> org.jboss.mx.loading.UnifiedClassLoader3@99176f{ url=file:/C:/Programme/jboss/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/test_ejb.jar/54.test_ejb.jar ,addedOrder=35}

                                    fine and OK!


                                    5.) Now make a redeployment of test_ejb.jar without deploying test_servlet.jar
                                    6.) Call again http://localhost:8080/test_servlet/
                                    The following output will occour:

                                    08:53:16,088 INFO [MainDeployer] Deployed package: file:/C:/Programme/jboss/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/test_ejb.jar

                                    08:53:19,803 ERROR [STDERR] ClassLoader lookup TestHome ----> org.jboss.mx.loading.UnifiedClassLoader3@185e90f{ url=file:/C:/Programme/jboss/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/test_ejb.jar/56.test_ejb.jar ,addedOrder=37}
                                    08:53:19,813 ERROR [STDERR] ClassLoader TestHome in Servlet ----> org.jboss.mx.loading.UnifiedClassLoader3@99176f{ url=file:/C:/Programme/jboss/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/test_ejb.jar/54.test_ejb.jar ,addedOrder=35}

                                    08:53:19,813 ERROR [STDERR] java.lang.ClassCastException
                                    08:53:19,813 ERROR [STDERR] at at.creato.test.web.TestServlet.doGetPost(Test
                                    Servlet.java:36)
                                    ....

                                    How can we solve this problem?

                                    Same probleme: we have an ejb call another ejb in the same vm -> redeployment of second ejb will also finish in a class cast exception...

                                    greetings
                                    Wolfgang


                                    As I am not able to attach the zip file containing sources and binaries (zipped 20 kb) i just put it on a server outside... :
                                    http://www.creato.at/jboss_forum/jboss3.2.x-test.zip