File Upload not working with Join

Splash Forums Rewrite Users File Upload not working with Join

This topic contains 6 replies, has 2 voices, and was last updated by  Christian Kaltepoth 7 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #25978



    first of all – great Job you’re doing! Keep it up!

    However, I seem to have a small problem with my fileUpload. In contrast to most other posts, I’m not using PrimeFaces.
    Here’s my setup:

    – Rewrite
    – JSF 2.2 (Mojarra 2.2.0)
    – Glassfish 4.0

    In a small example, I have following form:

    <h:form enctype="multipart/form-data">
      <h:inputFile value="#{fileModel.testFile}"/>
      <h:commandButton value="Upload" action="#{fileModel.upload()}"/>

    And a backing bean with the corresponding field (nothing interesting here to post).
    When I activate following rewrite rule:


    , the upload() method in the backing bean is fired (so I can react on the file upload).
    However, if I add the outbound rule


    or use the Join.path() way for adding the rule


    , the method is not fired. I don’t really understand why.
    I have attached a very minimal Maven project that is showing the behaviour.

    • This topic was modified 7 years, 10 months ago by  bmurauer.

    This could be caused by a common problem people run into.

    Could you have a look at the section “Why are file uploads not working correctly any more” in the FAQ?

    However, the entry just explains a verified workaround which works for Tomcat. I’ve no information about if this also work for Glassfish.



    yes, I have read every post imaginable out there…
    For now, we decided to only use the outbound rule and perform the file uploads with ajax, so the end user doesn’t see the unfiltered response address.



    I actually don’t really get who’s “error” this actually is. From what I’ve read in the faq and the solutions from the TomCat users, they allow the server to behave in a way that is not specified, but why are they even forced to do so? You stated that

    According to the Servlet spec HttpServletRequest.getParameter*() and HttpServletRequest.getPart*() can only be called from special Servlets for multipart/form-data request. Using these methods outside of such Servlets results in undefined behavior.

    Why is my servlet not a special Servlet for multipart/form-data?
    Which servlets are special Servlets for multipart/form-data?


    The problem is that, according to the Servlet spec, you are only allowed to call request.getParamater*() from servlets that have been configured to work with multipart requests. You can mark a servlet as “multipart”-capable using @MultipartConfig or with your web.xml.

    Now the real problem is, that Rewrite needs to call request.getParamater*() from a filter. According to the spec, this is not specified. The spec doesn’t forbid it, it just don’t mentions what should happen in this case.

    I don’t remember all the details, but AFAIK the request parameter map is empty in this case (at least for Tomcat without setting allowCasualMultipartParsing to true) which basically breaks Rewrite. As many JEE containers are using Tomcat internally, this may also be the case there.

    So as Rewrite is based on a Servlet filter and accessing certain request properties from a filter isn’t specified for multipart requests, you run into these problems.

    I know this is not very satisfying, but there is not much we can do about this. Setting allowCasualMultipartParsing is definitely a way to fix this issue for Tomcat. And my guess is that this also works for other containers which are based on Tomcat.



    OK that definitely clears things up, thanks!
    I guess I have to find another solution, since the allowCasualMultipartParsing does not seem to influence glassfish from what I’ve read.


    I’m not sure if allowCasualMultipartParsing works in Glassfish. I only know that context.xml seems to be supported in Glassfish. But perhaps not all the configuration properties!?!

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.