Tomahawk (FileUpload) argument mismatch
macumbr Nov 9, 2005 12:58 PMHi 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