8 Replies Latest reply on Feb 8, 2009 12:45 PM by andres andres

    fileUpload problem with seam 2.1.1

    andres andres Newbie

      Hello everyone,


      I am working wiht seam-2.1.1.GA, postgress and jboss-4.2.2.GA. I want to upload a file to the server and store some data,at the same time, in the database with the same entity.
      When I try to upload the file, I get a lot of error messages.


      The entity that store the data and manage de fileupload is the followin:



      public class Ejemplo implements java.io.Serializable {
      
              @Logger private Log log;
              
              private int idBos;
              private EjemploDis ejemploDistinciones;
              private Date fechaPublicacion;
              private Integer tipo;
              private Integer NBos;
              private Date fechaAlta;
      
              private byte[] data;
              private String fileName; 
              
              public Ejemplo() {
              }
      
              public Ejemplo(int idBos, EjemploDis ejemploDistinciones) {
                      this.idBos = idBos;
                      this.ejemploDistinciones = ejemploDistinciones;
              }
              public Ejemplo(EjemploDis ejemploDistinciones, Date fechaPublicacion,
                              Integer tipo, Integer NBos, Date fechaAlta,byte[] data,String fileName) {
                      
                      this.ejemploDistinciones = ejemploDistinciones;
                      this.fechaPublicacion = fechaPublicacion;
                      this.tipo = tipo;
                      this.NBos = NBos;
                      this.fechaAlta = fechaAlta;
                      this.data=data;
                      this.fileName=fileName;
              }
      
              
              @Id
              @Column(name = "id_bo", unique = true, nullable = false)
              @SequenceGenerator(name="identifier", sequenceName="sec_id_bo",allocationSize=1)
              @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="identifier")
              @NotNull
              public int getIdBos() {
                      return this.idBos;
              }
      
              public void setIdBos(int idBos) {
                      this.idBos = idBos;
              }
              
              @ManyToOne(fetch = FetchType.LAZY)
              @JoinColumn(name = "id_distinciones", nullable = false)
              @NotNull
              public EjemploDis getEjemploDis() {
                      return this.ejemploDistinciones;
              }
      
              public void setEjemploDis(EjemploDis ejemploDistinciones) {
                      this.ejemploDistinciones = ejemploDistinciones;
              }
              @Temporal(TemporalType.DATE)
              @Column(name = "fecha_publicacion", length = 13)
              public Date getFechaPublicacion() {
                      return this.fechaPublicacion;
              }
      
              public void setFechaPublicacion(Date fechaPublicacion) {
                      this.fechaPublicacion = fechaPublicacion;
              }
      
              @Column(name = "tipo")
              public Integer getTipo() {
                      return this.tipo;
              }
      
              public void setTipo(Integer tipo) {
                      this.tipo = tipo;
              }
      
              @Column(name = "n_bo")
              public Integer getNBos() {
                      return this.NBos;
              }
      
              public void setNBos(Integer NBos) {
                      this.NBos = NBos;
              }
              @Temporal(TemporalType.TIMESTAMP)
              @Column(name = "fecha_alta", length = 29)
              public Date getFechaAlta() {
                      return this.fechaAlta;
              }
      
              public void setFechaAlta(Date fechaAlta) {
                      this.fechaAlta = fechaAlta;
              }
      
              
              
              @Column(name = "data")
              //@NotNull
              public byte[] getData() {
                      return this.data;
              }
      
              public void setData(byte[] data) {              
                      log.info("Ejemplo {0}", "SetData");
                      if (data.length == 0 || data==null)
                              return;
                      this.data = data;               
              }
      
              @Column(name = "file_name", nullable = false, length = 100)
              @NotNull
              @Length(max = 100)
              public String getFileName() {
                      
      
                      if (data == null  || data.length == 0)
                              return this.fileName;
                      
                      try{
                                                      
                              File output = new File("c:/pdfEjemplo/");
                              if (!output.exists())
                                      output.mkdirs(); 
                              
                              output = new File("c:/pdfEjemplo/"+"_"+this.fileName);
                              
                              FileOutputStream oStream = new FileOutputStream(output);
                              if (!output.exists() || output.length() < data.length) {
                                      oStream.write(data); 
                              }
                              
                              oStream.close();
                              
                                                      
                              
                              
                      }catch(Exception e){
      
                      }
                      return this.fileName;
                      
              }
      
              public void setFileName(String fileName) {
                      if (fileName == null || fileName.length() == 0)
                              return;
                      this.fileName = fileName.replaceAll(" ", "_");
              }
              
      }
      



      I also insert in the components.xml this line:



       <web:multipart-filter create-temp-files="true" 
                                max-request-size="1000000" 
                                url-pattern="*.seam"/> 





      Here is part of the xhtml:



         <h:form id="ejemplo_bos" styleClass="edit" enctype="multipart/form-data">
                  <s:decorate id="tipoField" template="layout/edit.xhtml">
                      <ui:define name="label">Tipo</ui:define>
                      <h:inputText id="tipo"
                                value="#{ejemplo_bosHome.instance.tipo}">
                          <a:support event="onblur" reRender="tipoField" bypassUpdates="true" ajaxSingle="true"/>
                      </h:inputText>
                  </s:decorate>
      
      
               <s:decorate id="ficheroBoja" template="layout/edit.xhtml">
                      <ui:define name="label">Insertar PDF</ui:define>  
                                <s:fileUpload data="#{ejemplo_bosHome.instance.data}"       fileName="#{ejemplo_bosHome.instance.fileName}" accept="" />
                      </s:decorate>     
      
              </rich:panel>
      
              <div class="actionButtons">
      
                  <h:commandButton id="save"
                                value="Save"
                               action="#{ejemplo_bosHome.persist}"
                             disabled="#{!ejemplo_bosHome.wired}"
                             rendered="#{!ejemplo_bosHome.managed}"/>
      
                  <h:commandButton id="update"
                                value="Save"
                               action="#{ejemplo_bosHome.update}"
                             rendered="#{ejemplo_bosHome.managed}"/>
      
                  <h:commandButton id="delete"
                                value="Delete"
                               action="#{ejemplo_bosHome.remove}"
                            immediate="true"
                             rendered="#{ejemplo_bosHome.managed}"/>
      
                  <s:button id="cancelEdit"
                         value="Cancel"
                   propagation="end"
                          view="/EmpleoBojas.xhtml"
                      rendered="#{ejemplo_bosHome.managed}"/>
      
                  <s:button id="cancelAdd"
                         value="Cancel"
                   propagation="end"
                          view="/#{empty ejemplo_bosFrom ? 'EjemploList' : ejemplo_bosFrom}.xhtml"
                      rendered="#{!ejemplo_bosHome.managed}"/>
      
              </div>
          </h:form>



      The error messages that I get are:


      19:23:17,284 WARN  [lifecycle] executePhase(UPDATE_MODEL_VALUES 4,com.sun.faces.context.FacesContextImpl@d5b121) threw exception
      javax.el.ELException: /Bos_Edit.xhtml @113,128 data="#{ejemplo_bosHome.instance.data}": Error writing 'data' on type org.empleo.model.Ejemplo
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:101)
              at org.jboss.seam.ui.component.UIFileUpload.processUpdates(UIFileUpload.java:87)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIForm.processUpdates(UIForm.java:255)
              at org.ajax4jsf.component.AjaxViewRoot$2.invokeContextCallback(AjaxViewRoot.java:416)
              at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
              at org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:432)
              at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.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)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:86)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NullPointerException
              at org.empleo.model.Ejemplo.setData(Ejemplo.java:140)
              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 javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
              at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
              at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:93)
              at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
              at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
              at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
              ... 53 more
      19:23:17,284 WARN  [ExceptionFilter] handling uncaught exception
      javax.servlet.ServletException: /Bos_Edit.xhtml @113,128 data="#{ejemplo_bosHome.instance.data}": Error writing 'data' on type org.empleo.model.Ejemplo
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:86)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.el.ELException: /Bos_Edit.xhtml @113,128 data="#{ejemplo_bosHome.instance.data}": Error writing 'data' on type org.empleo.model.Ejemplo
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:101)
              at org.jboss.seam.ui.component.UIFileUpload.processUpdates(UIFileUpload.java:87)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIForm.processUpdates(UIForm.java:255)
              at org.ajax4jsf.component.AjaxViewRoot$2.invokeContextCallback(AjaxViewRoot.java:416)
              at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
              at org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:432)
              at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.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
      Caused by: java.lang.NullPointerException
              at org.empleo.model.Ejemplo.setData(Ejemplo.java:140)
              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 javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
              at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
              at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:93)
              at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
              at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
              at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
              ... 53 more
      19:23:17,284 WARN  [ExceptionFilter] exception root cause
      javax.el.ELException: /Bos_Edit.xhtml @113,128 data="#{ejemplo_bosHome.instance.data}": Error writing 'data' on type org.empleo.model.Ejemplo
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:101)
              at org.jboss.seam.ui.component.UIFileUpload.processUpdates(UIFileUpload.java:87)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
              at javax.faces.component.UIForm.processUpdates(UIForm.java:255)
              at org.ajax4jsf.component.AjaxViewRoot$2.invokeContextCallback(AjaxViewRoot.java:416)
              at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
              at org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:432)
              at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.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)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:86)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NullPointerException
              at org.empleo.model.Ejemplo.setData(Ejemplo.java:140)
              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 javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
              at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
              at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:93)
              at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
              at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
              at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
              at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
              ... 53 more



      (and more....)


      This is the first time that I work with seam and I am very lost, It is very important for me to solve this problem and I need your help.
      Thank you very much, and soory for my poor English :(


      Regarrds

        • 1. Re: fileUpload problem with seam 2.1.1
          Pawel Wrzeszcz Novice

          Well... you've got NPE in setData(). So either data or log is null. Check which one :) And I guess you should perform (data == null) check first ;)


          Cheers

          • 2. Re: fileUpload problem with seam 2.1.1
            andres andres Newbie

            The NPE comes from the data attribute of the s:uploadFile
            It looks like the data attribute is not recognize... I dont know what to do..


            Thank you very much.



            • 3. Re: fileUpload problem with seam 2.1.1
              Pawel Wrzeszcz Novice

              Hmm... why is the 'accept' empty in your s:fileUpload?


              -Pawep

              • 4. Re: fileUpload problem with seam 2.1.1
                andres andres Newbie

                Becase I want to accept all kinds of files.
                However, I also tried without the accept attribute and it doesnt work.


                I've been all the afternoon debuging the aplication, and I only found that all the attributes from the s:uploadFile were nulls. I think that the problem could be in the EntityHome class or in the page.xml of the view:


                Home:


                @Name("ejemplo_bosHome")
                public class EjemploHome extends EntityHome<Ejemplo> {
                     @Logger private Log log;
                     @In(create = true)
                     EjemploDisHome ejemploDistincionesHome;
                     
                     public void setEjemploIdBos(Integer id) {
                          setId(id);
                     }
                
                     public Integer getEjemploIdBos() {
                          return (Integer) getId();
                     }
                
                     @Override
                     protected Ejemplo createInstance() {
                                
                          Ejemplo ejemploBos = new Ejemplo();
                          return ejemploBos;
                     }
                
                     public void wire() {
                           log.info("HOME {0}", "CCCCCCCCCCCCCCC");
                          getInstance();
                          EjemploDis  ejemploDistinciones = ejemploDistincionesHome
                                    .getDefinedInstance();
                          if (ejemploDistinciones != null) {
                               getInstance().setEjemploDis (ejemploDistinciones);
                          }
                     
                     }
                
                     public boolean isWired() {
                          if (getInstance().getEjemploDis () == null)
                               return false;
                          return true;
                     }
                
                     public Ejemplo getDefinedInstance() {
                           log.info("HOME {0}", "DDDDDDDDDDDDDDDD");
                          return isIdDefined() ? getInstance() : null;
                     }
                     
                }



                And page.xml for the xthml I use:



                <?xml version="1.0" encoding="UTF-8"?>
                <page xmlns="http://jboss.com/products/seam/pages"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
                      no-conversation-view-id="/EmpleoBojasList.xhtml"
                      login-required="true">
                
                   <begin-conversation join="true" flush-mode="MANUAL"/>
                
                   <action execute="#{ejemplo_bosHome.wire}"/>
                
                   
                
                
                   <param name="ejemploFrom"/>
                   <param name="ejemploIdBoja" value="#{ejemplo_bosHome.empleoBojasIdBoja}"/>
                   <param name="empleoDisFrom"/>
                   <param name="empleoDistIdDistinciones" value="#{ejemploDisHome.empleoDistincionesIdDistinciones}"/>
                
                
                
                
                   <navigation from-action="#{ejemplo_bosHome.persist}">
                      <rule>
                         <end-conversation/>
                         <redirect view-id="/Ejemplo.xhtml"/>
                      </rule>
                   </navigation>
                
                   <navigation from-action="#{ejemplo_bosHome.update}">
                      <rule>
                         <end-conversation/>
                         <redirect view-id="/Ejemplo.xhtml"/>
                      </rule>
                   </navigation>
                
                   <navigation from-action="#{ejemplo_bosHome.remove}">
                      <rule>
                         <end-conversation/>
                         <redirect view-id="/Ejemplo.xhtml"/>
                      </rule>
                   </navigation>
                
                </page>
                




                Thank you!
                 

                • 5. Re: fileUpload problem with seam 2.1.1
                  Nicolas Bielza Newbie

                  log is null in Ejemplo.setData() because the class is not annotated with @Name. Either remove the log field from this class or give your entity a @Name to make it a Seam component. (Dependency injection only works for Seam components)

                  • 6. Re: fileUpload problem with seam 2.1.1
                    Carey Foushee Newbie
                    An Entity class does not need the @Name that's only for Seam components.  You are right that seam bi-injection does not occur on classes that are not Seam components).  My guess is the poster omitted the @Entity annotation that would have come before the class definition.

                    I ended up not storing the file in the database, I was using mysql and I found too many problem with size and format of the byte[].  I now use an UploadAction and store the InputStream to disk.  But a real good example of doing which still holds true for seam 2.1.1 (as far as I can tell) is at http://linuxbeans.blogspot.com/2007/10/image-handling-in-seam-apps-part-ii.html
                    • 7. Re: fileUpload problem with seam 2.1.1
                      andres andres Newbie

                      Great turorial Caray, thank you very much :).


                      The class has the @Entity anotation. Store the file in the database is a secondary objective, the main objective of this part of the web aplication, is to store a File in the server and store, at the same time, information about the file in the database( like the filename,the upload date, path where the file is store in the database, and (this is important) the id of an other entity that is relationated with the file in the data base)


                      • 8. Re: fileUpload problem with seam 2.1.1
                        andres andres Newbie

                        Any ideas?


                        Pleasu I need your help! Thank you!