6 Replies Latest reply on Mar 2, 2006 5:10 PM by macumbr

    Tomahawk (FileUpload) argument mismatch

    macumbr

      Hi all,

      First, sorry by my poor english.

      So...

      I´m developing a application using a Jboss Seam e Jsf. After solving some problems (I forgot put inside ejb3 file the seam.properties and the application don´t works, it gave an not found properties error :P, but the properties in the error were my internationalization properties... the message were '[[/dmm]] resource bundle br.com.navita.web.dmm.messages.message.properties could not be found', maybe this error message could be more especific, it´s only a suggestion :P).

      I stop in an error and I didn´t find the solution or others with same problem.

      I need upload a file in my web application... so I see tomahawk implementation (myfaces.apache.org), and it has a file upload module... it sound perfect.

      I write all necessary configurations, in a web.xml (create a filter) likewise written in http://myfaces.apache.org/tomahawk/overview.html, put the tomahawk.jar in my WEB-INF/lib and also in my server/default/lib when don´t work the first alternative. I also create the tomahawk.taglib.xml in the WEB-INF directory.

      And the web page has the field to put a file (click in Browse and select file) , but when I submit the form the exception in jboss appear.

      The exception is:

      15:21:38,593 ERROR [[/dmm]] /importDestinatario.xhtml @19,85 value="#{fileBean.fileMurilo}": br.com.navita.web.dmm.seam.bean.FileBean$$EnhancerByCGLIB$$b8e73359
      javax.faces.el.EvaluationException: /importDestinatario.xhtml @19,85 value="#{fileBean.fileMurilo}": br.com.navita.web.dmm.seam.bean.FileBean$$EnhancerByCGLIB$$b8e73359
       at com.sun.facelets.el.LegacyValueBinding.setValue(LegacyValueBinding.java:74)
       at javax.faces.component.UIInput.updateModel(UIInput.java:226)
       at javax.faces.component.UIInput.processUpdates(UIInput.java:165)
       at javax.faces.component.UIForm.processUpdates(UIForm.java:85)
       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:428)
       at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:153)
       at org.apache.myfaces.lifecycle.LifecycleImpl.updateModelValues(LifecycleImpl.java:239)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:81)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:92)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: Bean: br.com.navita.web.dmm.seam.bean.FileBean$$EnhancerByCGLIB$$b8e73359, property: fileMurilo
       at org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:372)
       at org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:148)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.setValue(LegacyELContext.java:197)
       at com.sun.el.parser.AstValue.setValue(AstValue.java:113)
       at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:246)
       at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
       at com.sun.facelets.el.LegacyValueBinding.setValue(LegacyValueBinding.java:68)
       ... 33 more
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:368)
       ... 39 more
      


      My web.xml is:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4"
       xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      
       <!-- Seam -->
      
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <!-- 120 second conversation timeout -->
       <context-param>
       <param-name>org.jboss.seam.core.manager.conversationTimeout</param-name>
       <param-value>120000</param-value>
       </context-param>
      
       <!-- MyFaces -->
       <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
       </context-param>
      
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <!-- Faces Servlet Mapping -->
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
       </servlet-mapping>
      
       <!-- Adicionado por Murilo para o File Upload -->
       <!-- O'Reilly MultiPart Filter -->
       <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
       <init-param>
       <param-name>maxFileSize</param-name>
       <param-value>20m</param-value>
       <description>Set the size limit for uploaded files.
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB
       </description>
       </init-param>
       <init-param>
       <param-name>uploadRepositoryPath</param-name>
       <param-value>/etc</param-value>
       </init-param>
       </filter>
      
       <!-- Filter Mappings -->
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>*.jsf</url-pattern>
       </filter-mapping>
       <!-- Fim do Adicionado por Murilo para o File Upload -->
      </web-app>
      


      My bean is:
      @Name("fileBean")
      @Scope(ScopeType.SESSION)
      public class FileBean {
      
       private UploadedFile fileMurilo;
      
       public void setFileMurilo(UploadedFile fileMurilo) {
       this.fileMurilo = fileMurilo;
       }
      
       @NotNull
       public UploadedFile getFileMurilo() {
       return this.fileMurilo;
       }
      }
      


      My action is:
      @Stateless
      @Name("importDestinatarioAction")
      @Interceptor(SeamInterceptor.class)
      @Conversational(ifNotBegunOutcome = "main")
      @LoggedIn
      public class DestinatarioImportadorAction implements DestinatarioImportador, Serializable {
      
       public DestinatarioImportadorAction() {
       System.out.println("\n\n\n\n\n\n\nn\n\n\n\n\noi");
       }
      
       private static final long serialVersionUID = 764502376907689873L;
      
       @In
       private transient FacesContext facesContext;
      
       @In
       private FileBean fileBean;
      
       public String importaArquivo() {
      
       return null;
       }
      
       public FileBean getFileBean() {
       return this.fileBean;
       }
      
       public void setFileBean(FileBean fileBean) {
       this.fileBean = fileBean;
       }
      }
      


      And my facelet is:
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:t="http://myfaces.apache.org/tomahawk"
       template="template.xhtml">
      
      <!-- content -->
      <ui:define name="content">
      <f:loadBundle basename="br.com.navita.web.dmm.messages.message" var="msgs"/>
      <div class="section">
       <h1>#{msgs.destinatarioImportacao}</h1>
      </div>
      <div class="section">
       <h:form enctype="multipart/form-data">
      
       <h:outputLabel for="fileId" value="#{msgs.geralArquivo}: "/>
       <t:inputFileUpload id="fileId" value="#{fileBean.fileMurilo}" required="true"/>
      
       <h:commandButton value="#{msgs.geralEnviar}" action="#{importDestinatarioAction.importaArquivo}"/>
       </h:form>
      </div>
      </ui:define>
      
      <!-- sidebar -->
      <ui:define name="sidebar">
      <h1>Continua uma vergonha</h1>
      <p>
       Mais vergonhoza q isso... soh a campanha do Flamengo no Brasileiro 2005
      </p>
      </ui:define>
      
      </ui:composition>
      


      I hope you to understand this... because I didn´t find anything about this crazy error.

      Any help is welcome. :P

      Maybe this is a some jar conflict. I Using jboss-4.0.3SP1 with all configuration in Microsoft Windows :S. I used the jboss installer to install,
      Jboss Seam 1.0beta1 and myfaces 1.1.0 and 1.1.1 when the application don´t works.

      Thanks in advance,

      Murilo Henrique Marecki Foltran

        • 1. Re: Tomahawk (FileUpload) argument mismatch
          macumbr

          Hi all,

          I rewrite the FileBean to:

          @Name("fileBean")
          @Scope(ScopeType.SESSION)
          public class FileBean {
          
           private Object fileMurilo;
          
           public void setFileMurilo(Object fileMurilo) {
           this.fileMurilo = fileMurilo;
           }
          
           @NotNull
           public Object getFileMurilo() {
           return this.fileMurilo;
           }
          }
          


          And it works!!!!!

          So I have to modify the code of my action to:

          @Stateless
          @Name("importDestinatarioAction")
          @Interceptor(SeamInterceptor.class)
          @Conversational(ifNotBegunOutcome = "main")
          @LoggedIn
          public class DestinatarioImportadorAction implements DestinatarioImportador, Serializable {
          
           public DestinatarioImportadorAction() {
           }
          
           private static final long serialVersionUID = 764502376907689873L;
          
           @In
           private transient FacesContext facesContext;
          
           @In
           private FileBean fileBean;
          
           @Begin
           public String importaArquivo() {
          
           Object object = this.fileBean.getFileMurilo();
           System.out.println(object.getClass().toString());
           return null;
           }
          
           public FileBean getFileBean() {
           return this.fileBean;
           }
          
           public void setFileBean(FileBean fileBean) {
           this.fileBean = fileBean;
           }
          }
          


          And the line System.out.println(object.getClass().toString());, of the DestintanatarioImportadorAction.importaAction, print in the log:

          [STDOUT] class org.apache.myfaces.custom.fileupload.UploadedFileDefaultMemoryImpl


          I tried instead of Object, I put classes which implements UploadedFile, it´s UploadedFileDefaultImplBase and UploadedFileDefaultMemoryImpl. And the same error occurs... so.. the problem are isolated, I think.

          I hope it helps,

          Best Regards and sorry again by the English,

          Murilo Henrique Marecki Foltran

          • 2. Re: Tomahawk (FileUpload) argument mismatch
            macumbr

            Hi again,

            When I make the cast of Object to UploadFile (or any subclass) I get an error:

            ClassCastException: Cannot cast org.apache.myfaces.custom.fileupload.UploadedFileDefaultMemoryImpl (id=486) to org.apache.myfaces.custom.fileupload.UploadedFileDefaultMemoryImpl


            it´s very strange!!!

            I don´t know how use this object!!!!! Do someone know?

            Do The cglib modify the class in execution time?

            If I can not class the class.... I come back to the start :S

            Anyone can help me?

            Thanks in Advance,

            Murilo

            • 3. Re: Tomahawk (FileUpload) argument mismatch
              gavin.king

              Looks like a classloader issue to me.

              • 4. Re: Tomahawk (FileUpload) argument mismatch
                macumbr

                You´re rigth, Gavin.
                It´s a classloader issue.

                :S

                Sorry for the incovenience,

                Murilo Henrique Marecki Foltran

                • 5. Re: Tomahawk (FileUpload) argument mismatch
                  ido_tamir

                  I would like to know how you solved the problem, because I am getting the same exception now.

                  thanks
                  ido

                  • 6. Re: Tomahawk (FileUpload) argument mismatch
                    macumbr

                    Hi ido,

                    My english is poor... sorry

                    It's a classloader problem...

                    To solve this I put all jars which application needs in a server/default/lib

                    And no more jars inside into jars of the application.

                    Into jars of the application, I have only the application jars. All the libs is inside of server/default/lib.

                    And works...

                    The duplicate jars causes errors like this...

                    I hope it help you...

                    cheers...

                    Murilo