Hi, I read about 50 posts, tried a lot of combination but a simple file upload is not working in my app (Seam 2B1, JBoss AS 4.2.1GA)...I made to work about 2 months ago (Seam 1.2.1GA, JBoss AS 4.0.X).
I tried SEAM POJO, SLSB, SFSB with CONVERSATION or EVENT scope, tried InputStream for data field but also byte[], add Seam Multipart Filter (org.jboss.seam.web.MultipartFilter) to web.xml but it doesn't work! this is my configuration: web.xml: | <?xml version="1.0" ?> | <web-app 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_5.xsd" | version="2.5"> | | <!-- Ajax4jsf --> | | <context-param> | <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> | <param-value>com.sun.facelets.FaceletViewHandler</param-value> | </context-param> | | <context-param> | <param-name>org.ajax4jsf.SKIN</param-name> | <param-value>blueSky</param-value> | </context-param> | | <!-- Seam --> | | <listener> | <listener-class>org.jboss.seam.servlet.SeamListener</listener-class> | </listener> | | <filter> | <filter-name>Seam Filter</filter-name> | <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> | </filter> | | <filter-mapping> | <filter-name>Seam Filter</filter-name> | <url-pattern>/*</url-pattern> | </filter-mapping> | | <servlet> | <servlet-name>Seam Resource Servlet</servlet-name> | <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class> | </servlet> | | <servlet-mapping> | <servlet-name>Seam Resource Servlet</servlet-name> | <url-pattern>/seam/resource/*</url-pattern> | </servlet-mapping> | | <!-- Facelets development mode (disable in production) --> | | <context-param> | <param-name>facelets.DEVELOPMENT</param-name> | <param-value>true</param-value> | </context-param> | | <!-- JSF --> | | <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> | | <servlet-mapping> | <servlet-name>Faces Servlet</servlet-name> | <url-pattern>*.seam</url-pattern> | </servlet-mapping> | | <security-constraint> | <display-name>Restrict raw XHTML Documents</display-name> | <web-resource-collection> | <web-resource-name>XHTML</web-resource-name> | <url-pattern>*.xhtml</url-pattern> | </web-resource-collection> | <auth-constraint/> | </security-constraint> | | <context-param> | <param-name>facelets.LIBRARIES</param-name> | <param-value>/WEB-INF/tomahawk.taglib.xml</param-value> | </context-param> | <!-- Tomahawk --> | <filter> | <filter-name>MyFacesExtensionsFilter</filter-name> | <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class> | <init-param> | <param-name>maxFileSize</param-name> | <param-value>20m</param-value> | </init-param> | </filter> | | <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages --> | <filter-mapping> | <filter-name>MyFacesExtensionsFilter</filter-name> | <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry --> | <servlet-name>Faces Servlet</servlet-name> | </filter-mapping> | | <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) --> | <filter-mapping> | <filter-name>MyFacesExtensionsFilter</filter-name> | <url-pattern>/faces/myFacesExtensionResource/*</url-pattern> | </filter-mapping> | | <!-- Parametri applicazione --> | <context-param> | <param-name>id_tipologia_admin</param-name> | <param-value>1</param-value> | </context-param> | <context-param> | <param-name>id_tipologia_editor</param-name> | <param-value>2</param-value> | </context-param> | <context-param> | <param-name>id_tipologia_guest</param-name> | <param-value>3</param-value> | </context-param> | <context-param> | <param-name>id_tipologia_iscritto_newsletter</param-name> | <param-value>4</param-value> | </context-param> | <context-param> | <param-name>id_lingua_default</param-name> | <param-value>1</param-value> | </context-param> | <context-param> | <param-name>id_configurazione</param-name> | <param-value>1</param-value> | </context-param> | | | </web-app> | | component.xml: | <?xml version="1.0" encoding="UTF-8"?> | <components xmlns="http://jboss.com/products/seam/components" | xmlns:core="http://jboss.com/products/seam/core" | xmlns:persistence="http://jboss.com/products/seam/persistence" | xmlns:drools="http://jboss.com/products/seam/drools" | xmlns:bpm="http://jboss.com/products/seam/bpm" | xmlns:security="http://jboss.com/products/seam/security" | xmlns:mail="http://jboss.com/products/seam/mail" | xmlns:web="http://jboss.com/products/seam/web" | xmlns:framework="http://jboss.com/products/seam/framework" | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | xsi:schemaLocation= | "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd | http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd | http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd | http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd | http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd | http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd | http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd | http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd | http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd"> | | <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/> | | <core:manager concurrent-request-timeout="500" | conversation-timeout="120000" | conversation-id-parameter="cid"/> | | <persistence:managed-persistence-context name="entityManager" | auto-create="true" | persistence-unit-jndi-name="java:/unica2EntityManagerFactory"/> | | <drools:rule-base name="securityRules"> | <drools:rule-files> | <value>/security.drl</value> | </drools:rule-files> | </drools:rule-base> | | <security:identity authenticate-method="#{authenticator.authenticate}" | security-rules="#{securityRules}"/> | | <event type="org.jboss.seam.notLoggedIn"> | <action expression="#{redirect.captureCurrentView}"/> | </event> | <event type="org.jboss.seam.postAuthenticate"> | <action expression="#{redirect.returnToCapturedView}"/> | </event> | | <mail:mail-session host="out.virgilio.it" port="25" debug="true" | ssl="false" /> | | <!-- For use with jBPM pageflow or process management --> | <!-- | <bpm:jbpm> | <bpm:process-definitions></bpm:process-definitions> | <bpm:pageflow-definitions></bpm:pageflow-definitions> | </bpm:jbpm> | --> | | <web:multipart-filter create-temp-files="true" | max-request-size="10000000" url-pattern="*.seam"> | </web:multipart-filter> | | <core:resource-loader> | <core:bundle-names> | <value>messages</value> | <value>messages_site</value> | <value>messages_articles</value> | <value>messages_articles_list</value> | <value>messages_articles_form</value> | </core:bundle-names> | </core:resource-loader> | | </components> | home.xhtml: | <?xml version="1.0" encoding="iso-8859-1"?> | <!DOCTYPE html 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: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:rich="http://richfaces.ajax4jsf.org/rich" | template="layout/template.xhtml"> | | <ui:define name="body"> | | <h:messages styleClass="message"/> | | <h:form enctype="multipart/form-data"> | <rich:panel> | <f:facet name="header">Test</f:facet> | | <s:decorate id="fileUploadDecoration" template="layout/edit.xhtml"> | <ui:define name="label">Image</ui:define> | <s:fileUpload id="file" data="#{uploadFile.uploadedFile}" | /> | </s:decorate> | | <div style="clear:both"/> | </rich:panel> | <div class="actionButtons"> | <h:commandButton value="Upload" action="#{uploadFile.parse}"> | | </h:commandButton> | </div> | </h:form> | </ui:define> | </ui:composition> | UploadFile.java: | package com.novaware.unica; | | import java.io.InputStream; | import java.io.Serializable; | | import javax.ejb.Remove; | import javax.ejb.Stateful; | import javax.ejb.Stateless; | | import org.jboss.seam.ScopeType; | import org.jboss.seam.annotations.Destroy; | import org.jboss.seam.annotations.In; | import org.jboss.seam.annotations.Logger; | import org.jboss.seam.annotations.Name; | import org.jboss.seam.annotations.Scope; | import org.jboss.seam.faces.FacesMessages; | import org.jboss.seam.log.Log; | | | @Name("uploadFile") | @Stateful // I also tried Stateless | @Scope(ScopeType.EVENT) //I also tried CONVERSATION | public class UploadFile implements IUploadFile { // Also tried Seam Pojo | @Logger | Log log; | | @In FacesMessages facesMessages; | | private byte[] uploadedFile; // I also tried with InputStream | private String uploadedFileName; | private String contentType; | | public void parse() throws Exception { | log.info("File:"+uploadedFile+" - "+uploadedFileName+" - "+contentType); | } | | public void setUploadedFile(byte[] uploadedFile) | { | this.uploadedFile = uploadedFile; | } | | public byte[] getUploadedFile() | { | return uploadedFile; | } | | public String getUploadedFileName() { | return uploadedFileName; | } | | | public void setUploadedFileName(String uploadedFileName) { | this.uploadedFileName = uploadedFileName; | } | | public String getContentType() { | return contentType; | } | | public void setContentType(String contentType) { | this.contentType = contentType; | } | | @Destroy @Remove | public void destroy() { | } | } | IUploadFile.java: | package com.novaware.unica; | | import java.io.InputStream; | | import javax.ejb.Local; | | @Local | public interface IUploadFile { | | public abstract void parse() throws Exception; | | public abstract void setUploadedFile(byte[] uploadedFile); | | public abstract byte[] getUploadedFile(); | | public abstract String getUploadedFileName(); | | public abstract void setUploadedFileName(String uploadedFileName); | | public abstract String getContentType(); | | public abstract void setContentType(String contentType); | | public void destroy(); | } | where is the error? thanks! Demetrio Filocamo View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077020#4077020 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4077020 _______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
