Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was having the same stacktrace in my project. I can explain why this is happening and few ways to fix it.</p> <p>So richfaces fileUpload component assumes that multipart request InputStream was not yet read from other places. But if you have in your application any filter that executes simple <code>request.getParameter(anyParamName)</code> this forces multipart request to read full inputstream and put everything into <code>request.getParts()</code> collection.</p> <p>When richfaces fileupload attempts to read something from inputstream it cannot do it because the stream cursor is at the end(this is in tomcat sources) and just returns -1; This causes richfaces to think that it can not read anything from the stream.</p> <p>To fix this you can remove all filters that force multipart request to parse inputStream. Also as a hot fix you can try to alter some of the richfaces classes like <code>MultipartRequest25</code> or <code>MultipartRequestParser</code>. </p> <p>I have added hot fix to <code>MultipartRequestParser</code> in order to check if request already has Parts and attempt to parse there parts into FileUploadParam. This is quite hacky checking the message of the exception but it can work as a hot fix.</p> <p>There exists non resolved issue in jboss jira that seems to be about this issue. You can check it out. I was adding a comment there too. <a href="https://issues.jboss.org/browse/RF-13061" rel="nofollow">https://issues.jboss.org/browse/RF-13061</a></p> <p><code></p> <pre><code>public void parse() throws FileUploadException { try { initialize(); while (!sequenceMatcher.isEOF()) { readNext(); } } catch (IOException e) { if(e.getMessage().equals(REQUEST_PROLOG_CANNOT_BE_READ)){ //means it can not read request prolog. maybe application server already read everything and stores data in parts try { if(request.getParts()!=null &amp;&amp; request.getParts().size()&gt;0){ Collection&lt;Part&gt; parts = request.getParts(); //parts seem to be complete files so get the headers and so on here //and create fileUploadItems from parts for(Part part:parts){ String headersString = part.getHeader("content-disposition"); Multimap&lt;String, String&gt; headers = LinkedListMultimap.create(); String[] split = headersString.split("\r\n"); for (String headerString : split) { parseParams(headerString, "; ", headers); } FileUploadParam param = createParam(headers); if (param == null) { continue; } param.create(); try{ int size = (int)part.getSize(); byte[] buf = new byte[size]; part.getInputStream().read(buf, 0, size); param.handle(buf, size); }finally{ param.complete(); } if (param.isFileParam()) { uploadedFiles.add(new UploadedFile25(param.getName(), param.getResource(), headers)); } else { parametersMap.put(param.getName(), param.getValue()); } } //return from the method if everything was successfull return; } } catch (Exception e1) { this.cancel(); throw new IllegalStateException("Could get Parts from the request", e1); } } this.cancel(); throw new FileUploadException(MessageFormat.format("Exception parsing multipart request: {0}", e.getMessage()), e); } } </code></pre> <p></code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload