3 Replies Latest reply on Sep 10, 2010 6:47 AM by rjbfigueroa

    ClassCast Exception in JBoss AS 6... HELP T_T

    rjbfigueroa Newbie

           Hi.  We have encountered an exception with the code that we have. When looking at the logs, it seems that there should be no error theoretically. Besides, the code was working with the previous versions (5,4,3)  ... Was there something changed in AS 6 that might have affected this  ?

       

       

      Here is the code together with the log:

       

       

      Java Code:
                              Object obj = lookupHome(SecurityManagerHome.JNDI_NAME, SecurityManagerHome.class);
                              System.out.println("****** SecurityManagerHome.class classloader [ "+SecurityManagerHome.class.getClassLoader().getClass().getName()+"]" );
                              System.out.println("****** obj instanceof "+obj.getClass().getName()+" ["+obj.getClass().getClassLoader().getClass().getName()+"]" );
                              Class[] intfcs = obj.getClass().getInterfaces();
                              if (intfcs!=null && intfcs.length>0){
                                 for (int i =0 ; i<intfcs.length; i++){
                                    System.out.println(i+": "+intfcs[i].getName());
                                 }
                              }
                              SecurityManagerHome ret = (SecurityManagerHome)lookupHome(SecurityManagerHome.JNDI_NAME, SecurityManagerHome.class);
      Corresponding Log:
      2010-09-06 08:18:38,465 DEBUG [org.apache.axis.SOAPPart] (http-0.0.0.0-8180-1) Exit: SOAPPart::getAsSOAPEnvelope
      2010-09-06 08:18:38,479 INFO  [STDOUT] (http-0.0.0.0-8180-1) ****** SecurityManagerHome.class classloader [ org.jboss.classloader.spi.base.BaseClassLoader]
      2010-09-06 08:18:38,480 INFO  [STDOUT] (http-0.0.0.0-8180-1) ****** obj instanceof $Proxy225 [org.jboss.classloader.spi.base.BaseClassLoader]
      2010-09-06 08:18:38,481 INFO  [STDOUT] (http-0.0.0.0-8180-1) 0: com.xxxxx.xxxxx.SecurityManagerHome
      2010-09-06 08:18:38,481 INFO  [STDOUT] (http-0.0.0.0-8180-1) 1: javax.ejb.Handle
      2010-09-06 08:18:38,481 ERROR [STDERR] (http-0.0.0.0-8180-1) java.lang.ClassCastException: $Proxy225 cannot be cast to com.xxxxx.xxxxx.SecurityManagerHome
      2010-09-06 08:18:38,482 ERROR [STDERR] (http-0.0.0.0-8180-1)    at com.xxxx.xxxxx.ServerManager.getSecurityManager(ServerManager.java:

                              Object obj = lookupHome(SecurityManagerHome.JNDI_NAME, SecurityManagerHome.class);

                              System.out.println("****** SecurityManagerHome.class classloader [ "+SecurityManagerHome.class.getClassLoader().getClass().getName()+"]" );

                              System.out.println("****** obj instanceof "+obj.getClass().getName()+" ["+obj.getClass().getClassLoader().getClass().getName()+"]" );

       

                              Class[] intfcs = obj.getClass().getInterfaces();

                              if (intfcs!=null && intfcs.length>0){

                                 for (int i =0 ; i<intfcs.length; i++){

                                    System.out.println(i+": "+intfcs[i].getName());

                                 }

                              }

       

                              SecurityManagerHome ret = (SecurityManagerHome)lookupHome(SecurityManagerHome.JNDI_NAME, SecurityManagerHome.class);

       

      Corresponding Log:

      2010-09-06 08:18:38,465 DEBUG [org.apache.axis.SOAPPart] (http-0.0.0.0-8180-1) Exit: SOAPPart::getAsSOAPEnvelope

      2010-09-06 08:18:38,479 INFO  [STDOUT] (http-0.0.0.0-8180-1) ****** SecurityManagerHome.class classloader [ org.jboss.classloader.spi.base.BaseClassLoader]

      2010-09-06 08:18:38,480 INFO  [STDOUT] (http-0.0.0.0-8180-1) ****** obj instanceof $Proxy225 [org.jboss.classloader.spi.base.BaseClassLoader]

      2010-09-06 08:18:38,481 INFO  [STDOUT] (http-0.0.0.0-8180-1) 0: com.xxxxx.xxxxx.SecurityManagerHome

      2010-09-06 08:18:38,481 INFO  [STDOUT] (http-0.0.0.0-8180-1) 1: javax.ejb.Handle

      2010-09-06 08:18:38,481 ERROR [STDERR] (http-0.0.0.0-8180-1) java.lang.ClassCastException: $Proxy225 cannot be cast to com.xxxxx.xxxxx.SecurityManagerHome

      2010-09-06 08:18:38,482 ERROR [STDERR] (http-0.0.0.0-8180-1)    at com.xxxx.xxxxx.ServerManager.getSecurityManager(ServerManager.java:74)

      -------------------
      Please help T_T pls pls pls

        • 3. Re: ClassCast Exception in JBoss AS 6... HELP T_T
          rjbfigueroa Newbie
          Thanks a lot guys, we were already able to fix it through this  community.  Not entirely, but got some important modules running.  Hope  this help others who might encounter the same problems.
          We have one sar, one ejb, about 5 war files and a  lot of shared jar files (dto, dao, stubs, name it).  They've been  running in prod on Jboss3 for around 4 years and some requirement forced  us to upgrade.  During tests, the whole setup was working in JBoss5 but  when we tried to put it in prod we got stuck with JBAS-6327 and  JBCL-109 (deadend tickets).  Thread state dump in jmx-console shows that  there is a thread that locks the rest of the other threads causing  JBoss5 to hang (that thread have similar stack trace with the one posted  in JBAS-6327).  Tried JBoss4 but seems to have the JBAS-6327 problem as  well -  had to move to JBoss 6.
          In JBoss6, we always get into problems and cycle  between ClassNotFoundException, Linkage Errors and  ClassNotFoundException.  Initially we don't want to mess up the  deployment packages that we know are working in JBoss 5, but it seems  that we don't have a choice.
          We spent a lot of time trying different setup and reading  references until finally we understood the ClassLoader sequence for  JBoss.  The knowledge that "siblings apps don't share libraries" got us  out of the problem loop and we eventually settle with the hierarchichal  folders structure inside server/default/deploy/.  Adding a verbose:class  param in run.conf helped us pinpoint the problems in class loading and  pick the right spot for each jar file (or just to check if it is still  necessary).
          At some point we also got stuck because of the limit  on how many folders deep is allowed in the deploy folder as a  default, but glad that we read that we can go deeper by enabling the  bean in deployer/directory-deployer-jboss-beans.xml.
          deploy/
            --company-apps/
          datasource.xml
          common-company-developed-jars
          --lib/
            apache-and-other-community-libraries
          --deploy.next/
          xxxx.ejb (only ejb-specific jars were left in the lib folder)
          xxxx.sar (only sar-specific jars were left in the lib folder)
          --deploy.webapps/
                  xxxx.war files  (jars that were already in the parent folders and their lib were removed)
          For  now, we plan to split the apps between the JBoss 3 and JBoss6 instances  and hopefully migrate everything when we see the latter become more  stable.