Exception in HttpRewriteWrappedRequest

Splash Forums Rewrite Users Exception in HttpRewriteWrappedRequest

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

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #25964

    shadogray
    Participant

    on Wildfly 8.0.0.Final (using Undertow) a ArrayIndexOutOfBoundsExc can occur for special requests (in my case Form POST enctype=”mime/multipart”):

    2014-03-05 07:11:47,679 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-12) 0: java.lang.ArrayIndexOutOfBoundsException: 0
    at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedRequest.getParameter(HttpRewriteWrappedRequest.java:83) [rewrite-servlet-2.0.10.Final.jar:2.0.10.Final]
    at com.sun.faces.context.RequestParameterMap.containsKey(RequestParameterMap.java:99) [jsf-impl-2.2.5-jbossorg-3.jar:]
    at java.util.Collections$UnmodifiableMap.containsKey(Collections.java:1337) [rt.jar:1.7.0_25]
    at com.sun.faces.renderkit.html_basic.FileRenderer.decode(FileRenderer.java:85) [jsf-impl-2.2.5-jbossorg-3.jar:]
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:831) [jboss-jsf-api_2.2_spec-2.2.5.jar:2.2.5]

    after introducing a length check everything works:

    @Override
       public String getParameter(final String name)
       {
          String[] strings = getParameterMap().get(name);
          if (strings != null && strings.length > 0)
          {
             return strings[0];
          }
          return super.getParameter(name);
       }
    #25967

    Hi!

    Thanks for reporting this issue, and the solution! I’ve patched the code and tested it. I could not reproduce your issue, but I can verify that your change is certainly not going to do any harm, so I’ve added it along with a test that should have (but as I said) did not reproduce the issue 🙂

    This should be in the next release in a few days.

    ~Lincoln

    #25995

    shadogray
    Participant

    Hi Lincoln,
    thanks to you for this incredible powerful framework!
    Regarding your question about repoducability that’s what the request looks like in my request dumper, dont know if it helps.

    Is it possible to bring out the next release soon? We are very limited in our access to SNAPSHOTS, so it is kind of unfortunate show stopper for a part of the application development.
    Sorry for molesting and many thanks again,
    Thomas

    21:23:31,345 INFO [atsw.filter.RequestDumperFilter] (default task-15) Request at Sat Mar 15 21:23:31 CET 2014 protocol=HTTP/1.1 remoteAddr=127.0.0.1 remoteHost=127.0.0.1 scheme=http serverName=localhost serverPort=8080 isSecure=false charEnc=UTF-8 contentLength=956 contentType=multipart/form-data; boundary=—————————119281973611429 locale=de_DE locales=de_DE,de,en_US,en
    Context: /mssms ServletPath: /faces
    Parameters:
    jfwid=7y08vYyFCk8Qd0MyI2xFqBra:0
    form:j_idt112=Parse
    form:j_idt101=CSV
    form=form
    form:j_idt91=
    javax.faces.ClientWindow=7y08vYyFCk8Qd0MyI2xFqBra:0
    form:inputFile=
    javax.faces.ViewState=1729365418924529720:5000054664557033827

    method=POST
    remoteUser=null
    requestedSessionId=7y08vYyFCk8Qd0MyI2xFqBra
    requestURI=/mssms/faces/csms/upload/upload.xhtml
    contextPath=/mssms cookie=JSESSIONID=7y08vYyFCk8Qd0MyI2xFqBra.atcsw631251 cookie=__utma=111872281.1879636267.1378383545.1390845621.1392828597.18 cookie=__utmz=111872281.1378383545.1.1.utmcsr Accept-Language=de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Cookie=JSESSIONID=7y08vYyFCk8Qd0MyI2xFqBra.atcsw631251; __utma=111872281.1879636267.1378383545.1390845621.1392828597.18; __utmz=111872281.1378383545.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) Host=localhost:8080 Content-Length=956 Referer=http://localhost:8080/mssms/faces/csms/upload/upload.xhtml?jfwid=7y08vYyFCk8Qd0MyI2xFqBra%3A0 Accept-Encoding=gzip, deflate User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 Content-Type=multipart/form-data; boundary=—————————119281973611429 Connection=keep-alive Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    =============================================
    21:23:31,369 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-15) 0: java.lang.ArrayIndexOutOfBoundsException: 0
    at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedRequest.getParameter(HttpRewriteWrappedRequest.java:83) [rewrite-servlet-2.0.10.Final.jar:2.0.10.Final]
    at com.sun.faces.context.RequestParameterMap.containsKey(RequestParameterMap.java:99) [jsf-impl-2.2.5-jbossorg-3.jar:]

    #25996

    This seems to be related to the file upload issue people seem to run into recently…

    IMHO the problem is that calling HttpServletRequest.getParameter*() for multipart requests is only allowed from Servlets that have been configured for multipart requests (Using @MultipartConfig for example). As Rewrite operates from a Servlet filter, the behavior of calling the getParameter*() methods is unspecified.

    In Tomcat calling getParameter*() for a multipart request from a filter won’t return the correct result unless you set allowCasualMultipartParsing for the context.

    From the Tomcat docs:

    Set to true if Tomcat should automatically parse multipart/form-data request bodies when HttpServletRequest.getPart* or HttpServletRequest.getParameter* is called, even when the target servlet isn’t marked with the @MultipartConfig annotation (See Servlet Specification 3.0, Section 3.2 for details). Note that any setting other than false causes Tomcat to behave in a way that is not technically spec-compliant. The default is false

    References:

    http://ocpsoft.org/rewrite/docs/faq
    http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
    http://stackoverflow.com/a/8050589/395181

    #26115

    shadogray
    Participant

    Hello,
    may I once again ask for a release fixing the abovementioned bug of Rewrite.

    I am not using anything spectacular, just vanilla wildfly 8.0.0.Final, or wildfly 8.1.0.CR1 and JSF 2.2 in an EE7 Project.
    So it is IMHO for the moment not possible to use the combination of Wildfly-8.0.0/JSF-2.2/Rewrite-2.0.11 + Standard FileUpload (<h:inputFile>).

    Minimum Example project attached.
    Best regards,
    Thomas

    Hmm, upload of example denied, because of security…
    trying rename of tar.gz to txt, please beware 🙂
    obviously ZIP is more appreciated, so here it is too..

    • This reply was modified 2 years, 3 months ago by  shadogray.
    #26139

    Hi,

    can you confirm that the current snapshots fix the ArrayIndexOutOfBoundsException you got before? If so, I agree that we should push out a release soon to get this work correctly on Wildfly.

    However, I think that file uploads still won’t work even with the current snapshots. I know that this is a huge problem, but if my assumptions about the cause of this incompatibility are correct (see my post above), then there is no way to fix this in the Rewrite code. Rewrite is based on a servlet filter and if the Servlet spec doesn’t allow to access parameters of multipart requests from filters, there is nothing we can do about that if the container doesn’t provide some kind of workaround (like Tomcat does it).

    Christian

    #26140

    shadogray
    Participant

    Hi Christian,
    I can definitely confirm, that above fix resolves the problem and JSF 2.2 FileUpload works fine in the mentioned environment.
    I first tested the correctness of the fix in our environment, and use the current SNAPSHOT as workaround since.
    I would be very glad, if you could provide the fix in an official release.

    Many thanks for your incredible work!
    Best regards,
    Thomas

    #26141

    Hey Guys,

    Yeah, we should push out a release. I’ll get on it tomorrow.

    ~Lincoln

    #26146

    Rewrite 2.0.12.Final has been released. Please give it a try and let us know that your problem was solved. Thanks!

    #26164

    shadogray
    Participant

    Hello Lincoln,
    sorry for late reply, many thanks for the release.
    I can confirm, that FileUpload works on Wildfly 8.0.0/8.1.0.CR1 – JSF2.2.
    That’s one week before go live 🙂

    Great work!
    Best regards,
    Thomas

    #26167

    Awesome! Thanks for confirming the fix! 🙂

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

You must be logged in to reply to this topic.

Comments are closed.