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 2 years, 3 months ago.

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

    ecs
    Participant

    Hello,
    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" />
    </h:form>
    
    
    <url-mapping id="test" >
    	<pattern value="/test" />
    	<view-id value="/test.xhtml" />
    </url-mapping> -->
    

    Any ideas?

    #25073

    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.

    #25074

    ecs
    Participant

    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.

    Attachments:
    1. rewrite.zip
    #25077

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

    #25096

    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}" />
    </h:form>
    

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

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

    Any idea? Which container did you use?

    #25097

    ecs
    Participant

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

    #25098

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

    #25128

    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.

    #25129

    Done!

    https://github.com/ocpsoft/rewrite/issues/136

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

    #25130

    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:

    https://github.com/ocpsoft/rewrite/issues/136#issuecomment-25644782

    #25137

    ecs
    Participant

    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 (https://glassfish.java.net/docs/4.0/application-development-guide.pdf) and added

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

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

    Any ideas?

    #25138

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

    #25139

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

    #25148

    ecs
    Participant

    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.

    #25149

    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:

    https://issues.apache.org/bugzilla/show_bug.cgi?id=49711

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

You must be logged in to reply to this topic.

Comments are closed.