Problem with h:inputFile

Splash Forums Rewrite Users Problem with h:inputFile

This topic contains 18 replies, has 4 voices, and was last updated by  syscreat 7 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
  • #25070


    I have been trying to use the JSF 2.2 h:inputFile tag with Rewrite. When I select a file and press the upload button only the getter of the h:inputFile value is invoked and not the setter. If I remove the Prettyfaces / Rewrite mapping for this site and access it via /test.xhtml it works.

    <h:form enctype="multipart/form-data">
    	<h:inputFile value="#{bean.file}" />
    	<h:commandButton value="Upload" />
    <url-mapping id="test" >
    	<pattern value="/test" />
    	<view-id value="/test.xhtml" />
    </url-mapping> -->

    Any ideas?


    Weird. I see no reason why PrettyFaces could be a problem. Could you perhaps provide a minimal sample app that reproduces this problem? This would help to find the root cause of this.



    Hi Christian,
    thank you for your reply. As attachment my minimal sample app. If you comment the url-mapping for the index.xhtml the setter is invoked.


    Thanks. I’ll have a look at it ASAP.


    Hey, I just gave your application a try. I deployed it to Wildfly Alpha4. Unfortunately the upload doesn’t seem to work at all. Even if I completely remove PrettyFaces from the application. I added an action method which doesn’t ever get executed if I click the button.

    <h:form enctype="multipart/form-data">
        <h:inputFile value="#{fileAction.file}" />
        <h:commandButton value="Upload" action="#{fileAction.action}" />

    It seems to have something to do with h:inputFile. If I use this code instead, the action method gets executed fine:

        <h:commandButton value="Upload" action="#{fileAction.action}" />

    Any idea? Which container did you use?



    Hi Christian,
    I use Glassfish4. The action method gets executed on Glassfish when I remove the PrettyFaces mapping.


    Ok, that is really weird. I’ll give Glassfish 4 a try in the next days when I find some time.


    Hey. I was able to reproduce this issue. It seems like there is a problem with multipart requests. I’ll create an issue to track this.



    Thanks a lot for pointing this out. I wonder why nobody noticed this bug earlier. 🙂


    Seems like for Tomcat you can fix this issue by setting:

    <Context .... allowCasualMultipartParsing="true">

    As the servlet container of Glassfish is also based on Tomcat, I think that it is the same issue.

    See my comment here:



    Hi Chriasitan,
    thank you very much for your quick solution! Unfortunately I wasn’t able to get it to work with Glassfish 4 yet. I created a context.xml in src/main/webapp/META-INF/context.xml as descriped in the Glassfish Development Guide Section 7-32 ( and added

    <Context allowCasualMultipartParsing="true">
      <!-- no content required -->

    When I try to upload a file I have the same behavior as before. The action and the setter are not invoked.

    Any ideas?


    Hmmm. This parameter has been added in some of the early Tomcat releases. Something like 7.0.8 or so. So I’m not sure if Glassfish also supports this parameter. Any idea which Tomcat version Glassfish uses (or is based on)?


    One of the links in the Glassfish docs refers to Tomcat 5.5, but that cannot be correct I guess. 🙂



    Hmm can’t find any further information on which Tomcat version Glassfish is based except from the link to a Tomcat 5.5 documentation in the Glassfish docs but the servlet container used by Glassfish is version 3.1.

    Is there maybe an other way to get rewrite working with Glassfish? When I get it right it is also not recommended to set allowCasualMultipartParsing true in the Tomcat docs

    Note that any setting other than false causes Tomcat to behave in a way that is not technically spec-compliant.


    I think the Tomcat docs don’t say “it is not recommended”, they just say that accessing the mentioned methods from outside a corresponding Servlet is not strictly spec compliant. IMHO this is a huge difference. And from a technical perspective I don’t see any reason why parsing the request a bit earlier during request processing should be a problem.

    I’m not sure if there is another way to get Rewrite working well with multipart requests. Rewrite has to access the request parameters for the rewriting and if the container doesn’t allow to access them, there is IMHO nothing that we can do about it.

    I recommend to ask how to enable this behavior in the Glassfish forums. I think there will be someone that knows more about these Glassfish internals. Or perhaps file an issue on the issue tracker.

    BTW: Here is the original Tomcat issue:

Viewing 15 posts - 1 through 15 (of 19 total)

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

Comments are closed.