2 Replies Latest reply on Jan 26, 2010 10:26 AM by blabno

    DataScrollerEvent and Classloader Issue

    Drew Kutchar Newbie

      I get the following ClassCastException:

      ClassCastException: Cannot cast org.richfaces.event.DataScrollerEvent to org.richfaces.event.DataScrollerEvent

      When calling:

      <rich:datascroller align="left" for="table" actionListener="#{action.scrollListener}"/>

      public void scrollListener(final ActionEvent event) {
           final DataScrollerEvent scrollerEvent = (DataScrollerEvent) event;
           log.info("scroll #0 #1", scrollerEvent.getNewScrolVal(), scrollerEvent.getOldScrolVal());

      I did a grep for DataScrollerEvent at the root of my project and this is what I got:

      Binary file exploded-archives/GotPrintSeam.ear/lib/richfaces-api.jar matches
      Binary file exploded-archives/GotPrintSeam.war/WEB-INF/lib/richfaces-ui.jar matches
      Binary file lib/richfaces-api.jar matches
      Binary file lib/richfaces-ui.jar matches

      Why are there two versions of the same class in separate jars? JBoss uses different classloaders for loading the libs in the war and the ear so I think that's what's causing the problem. Since my action is a SFSB it's loaded using the EAR classloader and I think the RichFaces is loaded using the WAR classloader.

      Is this a bug? Is there a fix/workaround?

      I am using Seam 2.0.1.GA with RichFaces that was bundled with 2.0.1.GA and JBoss 4.2.2.GA

        • 1. Re: DataScrollerEvent and Classloader Issue
          Karunakara reddy Vasipalli Newbie

          Hi Drew,
          Can you please share, how did you over come the problem of 'more than one classloaders is loading the war and ear'?

          I am also facing the problem of class-lodder. In my case classloders tried to load org.apache.commons.logger.Log more than once.

          Thanks for you time in advance.


          • 2. Re: DataScrollerEvent and Classloader Issue
            blabno Master

            This is not a bug. If you use seam-gen then edit your deployed-jar.list for war and ear.
            If you need the same library in both ejb jar and war and you want to pass objects from that library between ejb jar and war you need to put that library into ear/lib which will make it available for both zips.

            Note that such exception points that you use richfaces - presentation library - in business layer (ejb) which is considered to be a poor design.