1 2 Previous Next 16 Replies Latest reply on Dec 21, 2007 8:50 AM by dloebbe

    s:fileUpload not actually sending output?

      I've been struggling with getting s:fileUpload to work with our application; from reading the message boards it seems as if we're doing everything right, but obviously something's missing. This is with Seam 2.0.0.B1, fwiw.

      Our components.xml file contains:

      <web:multipart-filter create-temp-files="false" max-request-size="1000000"/>


      Our web.xml file is, in its entirety:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      
       <distributable />
      
       <display-name>Control Panel</display-name>
      
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       </welcome-file-list>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.html</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</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>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <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.richfaces.SKIN</param-name>
       <param-value>plain</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>/WEB-INF/components/core.taglib.xml;/WEB-INF/domain/core.taglib.xml</param-value>
       </context-param>
      
       <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
       </filter>
      
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter>
       <filter-name>Seam Redirect Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
       </filter>
      
       <filter>
       <filter-name>Seam Exception Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>Seam Exception Filter</filter-name>
       <url-pattern>*.xhtml</url-pattern>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>Seam Redirect Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
      </web-app>


      Within the page template, we're using this to create the form:

      <h:form id="main" styleClass="k_main clearfix" enctype="multipart/form-data">


      And finally, in the page itself, we're using the tag as follows:

      <s:fileUpload id="picture" data="#{campaign.logo}" contentType="#{campaign.logoType}" fileName="#{campaign.logoFileName}"/>


      All I really care about is the data stream - I've tried adding and removing contentType, accepts, et cetera. In the bean, the fields are defined as follows:

       private byte[] logo;
       private String logoType;
       private String logoFileName;
      
       .....
      
       @Lob
       @Column(length = 1048576)
       public byte[] getLogo() {
       return logo;
       }
      
       public void setLogo(byte[] logo) {
       this.logo = logo;
       }
      
       @Transient
       public String getLogoType() {
       return logoType;
       }
      
       public void setLogoType(String logoType) {
       this.logoType = logoType;
       }
      
       @Transient
       public String getLogoFileName() {
       return logoFileName;
       }
      
       public void setLogoFileName(String logoFileName) {
       this.logoFileName = logoFileName;
       }
      


      Interestingly, breakpoints on the set methods show that setLogo() is called with a null value, but that setLogoFileName() et al are never called. So we're obviously missing something in the configuration. Any help will be greatly appreciated.

        • 1. Re: s:fileUpload not actually sending output?
          shane.bryzak

          You could try setting a breakpoint in FileUploadRendered.doDecode() and confirm that the request is indeed recognized as a MultipartRequest. Other than that, I suggest you look at the seamspace example (register2.xhtml) as it uses s:fileUpload also.

          • 2. Re: s:fileUpload not actually sending output?

            Thanks, I'll pull the code down and try that breakpoint. As for the examples, I've been looking at the wiki one - are there any other files (other than those that I posted above) that I should be checking?

            • 3. Re: s:fileUpload not actually sending output?

              Its a bit of a late response, but I'm not seeing any such code. We're using Seam 2.0.0.B1 running on JBoss 4.2.1.GA if it makes a difference.

              It seems from looking through the debugger at the tree that it is being seen as a multipart request; checking the request facade shows that, as an example, org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler.handled=true...

              The file appears to be making it some ways in. This was found in the attributes:

              org.apache.myfaces.trinidadinternal.config.upload.UploadedFileProcessorImpl.UploadedFilesInfo=org.apache.myfaces.trinidadinternal.config.upload.UploadedFileProcessorImpl$RequestInfo@451790 Digging further showed totalBytesInMemory=11219 which is about right.

              It appears as org.apache.myfaces.trinidadinternal.config.upload.UploadedFiles@51152c as well...

              I'm just not sure where its dropping off between there and our "...setLogo(byte[])" method.

              NOTE: MultipartFilter does not appear in the list of filters shown by the debugger. Also, the request does not appear to be a MultipartRequest, although with as much nesting as there is its hard to say.

              • 4. Re: s:fileUpload not actually sending output?

                GOT IT - For anyone else who's searching and finds this ...

                We had the trinidad jars in our library, even though we weren't using them. We were referencing the namespace in the xmlns section of the page, but that was it. Removing the reference and the jar files themselves suddenly made s:fileUpload send data!

                I also added org.jboss.seam.web.MultipartFilter manually. That allows us to have all of our form tags be multipart (set in our template) - not sure if this is "bad", but it seems to work just fine.

                Now all I need to do is figure out why I'm getting a NumberFormatException when outputting the image from the byte[] - but that's a new problem!

                • 5. Re: s:fileUpload not actually sending output?
                  pmuir

                  So you are saying that s:fileUpload doesn't work with Trinidad?

                  Can you try with Seam 2 CR3? If it doesn't work, please file a JIRA issue.

                  • 6. Re: s:fileUpload not actually sending output?

                    That certainly seems to have been the culprit. I think its because Trinidad automatically (somehow) installed a filter even though nothing was put into web.xml about it that removed the image and placed it into its own UploadedFiles object - so Seam never saw that it was sent, which is reasonable as far as that goes.

                    When we upgrade from 2.0.0.B1 to anything greater I get some exceptions that I haven't been able to take the time to chase down - after this next release cycle a couple of weeks from now I'll push through that, get everything sync'd to the latest version, and retest - and file appropriate issues as needed.

                    • 7. Re: s:fileUpload not actually sending output?
                      shane.bryzak

                      I also noticed in your web.xml you have both the Seam redirect and exception filters configured separately. Since you are using SeamFilter, you don't need these (SeamFilter includes them already).

                      If you could post the stack traces for your exceptions I might be able to tell what's wrong from that.

                      • 8. Re: s:fileUpload not actually sending output?
                        wiberto

                        Was this narrowed down to a conflict with Trinidad? I'm getting a null InputStream, and everything looks fine in terms of the xhtml and the backing bean.

                        I tried removing Trinidad, but the Tomcat deployer is still complaining about the TrinidadListener somewhere, but I don't know where it is since I removed all references to Trinindad.

                        Thanks,

                        Jose

                        • 9. Re: s:fileUpload not actually sending output?
                          wiberto

                          I resolved the TrinidadListener class not def found (it was some JBoss stuff hanging around in the tmp deployer folder)

                          So I'm seeing the same behavior. With Trinidad the InputStream is null. I actually debugged it and the multipart parser is invoked and it tries to parse the request, but when it gets the input stream from the HttpRequest and reads it the first read returns -1 so it gets out of the loop.

                          After taking out Trinidad evertyhing works fine and the data is passed to the bean as expected.

                          Was an issue entered for it?

                          Thanks,

                          Jose

                          • 10. Re: s:fileUpload not actually sending output?
                            pmuir

                            No.

                            • 11. Re: s:fileUpload not actually sending output?
                              wiberto

                              So what's the next step here? Entering a JIRA issue?

                              • 12. Re: s:fileUpload not actually sending output?
                                mdesignz

                                Has anything happened with this? Appears to be an issue in 2.0.GA as well.

                                • 13. Re: s:fileUpload not actually sending output?
                                  pmuir

                                  You need to create a jira issue.

                                  • 14. Re: s:fileUpload not actually sending output?
                                    mdesignz

                                    Just tried to do that, but JIRA faulted with:

                                    The requested resource (No view for result [error] exists for action [ViewIssue]) is not available.

                                    During the submit.

                                    1 2 Previous Next