[richfaces-issues] [JBoss JIRA] (RF-13061) r:fileUpload stops working: "Request prolog cannot be read"

Valiantsin Shukaila (JIRA) jira-events at lists.jboss.org
Wed Jun 26 16:02:22 EDT 2013


    [ https://issues.jboss.org/browse/RF-13061?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12785263#comment-12785263 ] 

Valiantsin Shukaila edited comment on RF-13061 at 6/26/13 4:02 PM:
-------------------------------------------------------------------

I have the same stacktrace with Tomcat 7.0.41 and Richfaces 4.3.1.Final. and JSF 2.2
I have debugged to the deep of Tomcat sources and found out that when 

{code:title=org.richfaces.request.ByteSequenceMatcher|borderStyle=solid}
protected void prefillBuffer(int usedLength) throws IOException {
        if (usedLength > readLength) {
            throw new IllegalArgumentException();
        }

        if (usedLength != readLength && usedLength != 0) {
            System.arraycopy(buffer, usedLength, buffer, 0, readLength - usedLength);
        }

        readLength -= usedLength;

        while (!bufferEOF) {
            int remaining = buffer.length - readLength;
            if (remaining <= 0) {
                break;
            }
            int read = inputStream.read(buffer, readLength, remaining);

{code} 

the read here results into -1 because full inputstream is already read by tomcat ServletFileUpload and bytes was put into request.getParts() collection.

This happens when any filter in the chain executes request.getParameter() method which forces tomcat to read request input stream.
Maybe it should be some backup for this case to check if request.getParts() has initialized and use them to compose a file instead of always reading bytes from request input stream?

                
      was (Author: Trims):
    I have the same stacktrace with Tomcat 7.0.41 and Richfaces 4.3.1.Final. and JSF 2.2
I have debugged to the deep of Tomcat sources and found out that when 

{code:title=org.richfaces.request.ByteSequenceMatcher|borderStyle=solid}
protected void prefillBuffer(int usedLength) throws IOException {
        if (usedLength > readLength) {
            throw new IllegalArgumentException();
        }

        if (usedLength != readLength && usedLength != 0) {
            System.arraycopy(buffer, usedLength, buffer, 0, readLength - usedLength);
        }

        readLength -= usedLength;

        while (!bufferEOF) {
            int remaining = buffer.length - readLength;
            if (remaining <= 0) {
                break;
            }
            int read = inputStream.read(buffer, readLength, remaining);

{code} 

the read here results into -1 because full inputstream is already read by tomcat ServletFileUpload and bytes was put into request.getParts() collection.

This happens when any filter in the chain executes request.getParameter() method which forces tomcat to read request input stream.
Maybe this should be some backup for this case to check if request.getParts() has initialized and use them to compose a file instead of always reading bytes from request input stream?

                  
> r:fileUpload stops working: "Request prolog cannot be read"
> -----------------------------------------------------------
>
>                 Key: RF-13061
>                 URL: https://issues.jboss.org/browse/RF-13061
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-input
>    Affects Versions: 5.0.0.Alpha1
>            Reporter: Juergen Zimmermann
>            Assignee: Stuart Douglas
>             Fix For: 5.0.0.Alpha2
>
>
> I just tried r:fileUpload with the current snapshot for WildFly 8.0.0.Alpha2 (changed Mojarra 2.2.0 to 2.1.23). It actually looks pretty good. However, I'm getting this stacktrace for fileUpload:
> {code}
> 16:33:44,571 SEVERE [org.richfaces.log.Application] Exception parsing multipart request: Request prolog cannot be read: org.richfaces.ui.input.fileUpload.FileUploadException: Exception parsing multipart request: Request prolog cannot be read
> 	at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56) [jsf-impl-2.1.23.jar:2.1.23]
> 	at java.util.Collections$UnmodifiableMap.get(Collections.java:1339) [rt.jar:1.7.0_21]
> 	at com.sun.faces.facelets.tag.ui.UIDebug.debugRequest(UIDebug.java:168) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.context.flash.ELFlash$PreviousNextFlashInfoManager.decode(ELFlash.java:1225) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.context.flash.ELFlash.getCurrentFlashManager(ELFlash.java:1059) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.context.flash.ELFlash.doPrePhaseActions(ELFlash.java:557) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:215) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.23.jar:2.1.23]
> 	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.23.jar:2.1.23]
> 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jsf-api-2.1.23.jar:2.1]
> 	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:87) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:138) [undertow-websockets-jsr-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:56) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
> 	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:115) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:55) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:65) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:70) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at org.wildfly.extension.undertow.security.SecurityContextCreationHandler.handleRequest(SecurityContextCreationHandler.java:54)
> 	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:127) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:114) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:47) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:90) [undertow-servlet-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.server.HttpHandlers.executeRootHandler(HttpHandlers.java:36) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:607) [undertow-core-1.0.0.Alpha19.jar:1.0.0.Alpha19]
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
> 	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
> Caused by: java.io.IOException: Request prolog cannot be read
> 	at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148) [richfaces-5.0.0.Alpha1.jar:5.0.0.Alpha1]
> 	... 43 more
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the richfaces-issues mailing list