2 Replies Latest reply on Mar 28, 2008 1:50 PM by Mark LoSacco

    fileUpload - problem updating model

    Mark LoSacco Newbie

      I am attempting to create a simple form in my application that allows the user to upload an image and store it in the database.


      When the form is submitted after the image is selected I am getting the following exception:




      16:26:23,936 WARN  [lifecycle] executePhase(UPDATE_MODEL_VALUES 4,com.sun.faces.context.FacesContextImpl@32ba35) threw exception
      
      javax.el.PropertyNotFoundException: /super/SkinEdit.xhtml @18,24 data="#{skinHome.instance.skinBanner}": Property 'skinBanner' not writable on type [B
      
           at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:95)
      
           at org.jboss.seam.ui.component.UIFileUpload.processUpdates(UIFileUpload.java:60)
      
           at javax.faces.component.UIForm.processUpdates(UIForm.java:255)
      
           at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1056)
      
           at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:706)
      
           at org.ajax4jsf.component.AjaxViewRoot.access$101(AjaxViewRoot.java:57)
      
           at org.ajax4jsf.component.AjaxViewRoot$2.invokeRoot(AjaxViewRoot.java:291)
      
           at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
      
           at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:170)
      
           at org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:305)
      
           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.MultipartFilter.doFilter(MultipartFilter.java:80)
      
           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:141)
      
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      
           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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      
           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(Unknown Source)



      Here is my entity:



      @Entity
      
      @Table(name = "skin", catalog = "ludb")
      
      public class Skin implements java.io.Serializable {
      
           private static final long serialVersionUID = -9025450505108960382L;
      
      
           private Integer skinId;
      
           private String skinName;
      
           private byte[] skinBanner;
      
           private String skinBannerType;
      
      
           public Skin() {
      
           }
      
      
           @Id
      
           @GeneratedValue(strategy = IDENTITY)
      
           @Column(name = "SKIN_ID", unique = true, nullable = false)
      
           public Integer getSkinId() {
      
                return this.skinId;
      
           }
      
      
           public void setSkinId(Integer skinId) {
      
                this.skinId = skinId;
      
           }
      
      
           @Column(name = "SKIN_NAME", nullable = false, length = 40)
      
           @NotNull
      
           @Length(max = 40)
      
           public String getSkinName() {
      
                return this.skinName;
      
           }
      
      
           public void setSkinName(String skinName) {
      
                this.skinName = skinName;
      
           }
      
      
              @Lob
      
           @Column(name = "SKIN_BANNER")
      
           @Basic(fetch = FetchType.LAZY)
      
           public byte[] getSkinBanner() {
      
                return this.skinBanner;
      
           }
      
           
      
           void setSkinBanner(byte[] skinBanner) {
      
                this.skinBanner = skinBanner;
      
           }
      
      
           @Transient
      
           public String getSkinBannerType() {
      
                return skinBannerType;
      
           }
      
           public void setSkinBannerType(String type) {
      
                this.skinBannerType= type;
      
           }
      
      }



      Here is my form page:



      <!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: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:a="http://richfaces.org/a4j"
      
                      xmlns:rich="http://richfaces.org/rich"
      
                      template="layout/template.xhtml">
      
                             
      
      <ui:define name="body">
      
          <h:form id="skin" enctype="multipart/form-data" styleClass="edit">
      
                      <s:fileUpload id="bannerImg" 
      
                          data="#{skinHome.instance.skinBanner}" 
      
                          contentType="#{skinHome.instance.skinBannerType}"
      
                          accept="image/*" />
      
           <h:commandButton id="update" 
      
                                value="Save" 
      
                               action="#{skinHome.update}"
      
                             rendered="#{skinHome.managed}"/>
      
      </h:form>    
      
      </ui:define>
      
      



      I have setup my components.xml with:



           <component class="org.jboss.seam.web.MultipartFilter">
      
                <property name="createTempFiles">true</property>
      
                <property name="maxRequestSize">4194304</property>
      
           </component>
      
      


      and my web.xml with:


       <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>



      Can anyone spot why my model can't be updated properly?
      Much appreciated.