3 Replies Latest reply on Apr 7, 2008 9:08 AM by andrei_exadel

    seam 2.1, richfaces 3.2.0 and fileUpload

    koatto

      i'm using richfaces 3.2.0 and seam 2.1 and im facing problems on getting rich:fileUpload work. It seems the component can't find the listener method.

      this is what i get :

      |Caused by: javax.faces.el.MethodNotFoundException: /test.xhtml @17,112 fileUploadListener="#{uploadHandler.fil
      eUploadListener}": Method not found: mk.common.UploadHandler@1af0d15.fileUploadListener(org.richfaces.event.Up
      loadEvent)
       at ||com.sun.facelets.el.LegacyMeth||odBinding.invoke(LegacyMethodBinding.java:71)
       at org.richfaces.component.UIFileUpload.broadcast(UIFileUpload.java:160)
       at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:316)
       at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:289)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:248)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:404)
       at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       ... 41 more|


      this is my component's code :

      import java.io.File;
      import java.io.IOException;
      
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.log.Log;
      
      
      import org.richfaces.model.UploadItem;
      
      @Name("uploadHandler")
      public class UploadHandler {
       @Logger
       Log log;
      
       public void fileUploadListener(org.richfaces.event.UploadEvent event) {
       if(event==null){
       log.debug("null upload event");
       return;
       }
       UploadItem item = event.getUploadItem();
      
       String name = "unnamed_attachment";
       byte[] data = item.getData();
      
       if (item.isFile()) {
       name = item.getFileName();
       data = item.getData();
       File file = item.getFile();
       log.debug(
       "uploaded "+name+
       " - length= "+( (data==null)?0:data.length) +
       " tmpFile="+file.getAbsoluteFile()
       );
       }
       }
      }


      and that's my page

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:rich="http://richfaces.org/rich" >
       <HEAD>
       <title>test fileupload</title>
       </HEAD>
      
       <body>
       <h:form>
       <rich:fileUpload id="upload" fileUploadListener="#{uploadHandler.fileUploadListener}" maxFilesQuantity="2">
       <f:facet name="label">
       <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
       </f:facet>
       </rich:fileUpload>
       </h:form>
       </body>
      
      </html>


      If i remove the event parameter from the listener methd it gets recognized and the page works, but i obviously have no access to anything.
      I think the seam's el handler is producing some bad effect.

      Thanks.



        • 1. Re: seam 2.1, richfaces 3.2.0 and fileUpload
          andrei_exadel

          Hi,

          It likes strangely.

          I think the problem is not in File Upload component.

          I can suggest that system has two UploadEvent in class loaders. May be you have twice added RF jars in your application or something else.

          Currently i see that file upload fires under seam 2.1 without problems.

          • 2. Re: seam 2.1, richfaces 3.2.0 and fileUpload
            koatto

            rf jar were linked by application.xml and placed into war\web-inf\lib.
            i left just the ones in the root ear folder end everything worked fine.
            Thanks a lot.

            Why having more than one copy of the class in the classpath was breaking up
            everything?

            thanks.

            • 3. Re: seam 2.1, richfaces 3.2.0 and fileUpload
              andrei_exadel

              Because all classes inside class loader are unique in spite of they have the same names and they are in the same jars.

              I think in our case the problem is somewhere in event/listener way...

              For example listener was started using class from the first jar. But method was invoked with parameter of class from another jar.

              I'm not sure that I'm right in details :)

              But anyway there is a wrong thing to link the jar twice.