You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thad Humphries <th...@gmail.com> on 2016/05/06 16:32:30 UTC

Tomcat 8.5 NullPointerException on getSubmittedFileName() with HTTP/2

I have lifted from the GlassFish tutorial a simple file upload servlet
example. When I run this with Tomcat 8.5 and HTTPS (Http11NioProtocol), it
works fine, uploading a file to the /tmp directory:

  ...
  protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html;charset=UTF-8");

    // Create path components to save the file
    final String path = request.getParameter("destination");
    final Part filePart = request.getPart("file");
    final String fileName = filePart.getSubmittedFileName();
    ...

However when I add <UpgradeProtocol
className="org.apache.coyote.http2.Http2Protocol" /> to the <Connector> in
servlet.xml, the servlet fails with a NullPointerException on
filePart.getSubmittedFileName().

Surprised, I tried uploading a .WAR through the Tomcat Manager with HTTP/2
enabled. Sure enough, it failed with the message "FAIL - File upload
failed, no file". When I track this down in the 8.5 source, I find the
error at line #239 of org.apache.catalina.manager.HTMLManagerServlet, which
indicates that request.getPart("deployWar") is returning null.

Has anyone else seen this?

I'm am running Tomcat 8.5, Java 1.8.0_91, MacOS 10.10.5, and Chrome 50.

-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v. 121-24)

Re: Tomcat 8.5 NullPointerException on getSubmittedFileName() with HTTP/2

Posted by Thad Humphries <th...@gmail.com>.
For the record, this problem has been fixed in Tomcat 8.5.3 (see
https://bz.apache.org/bugzilla/show_bug.cgi?id=59564).

I have also been able to upload files using Apache Commons FileUpload 1.3.1.

On Fri, May 6, 2016 at 12:32 PM, Thad Humphries <th...@gmail.com>
wrote:

> I have lifted from the GlassFish tutorial a simple file upload servlet
> example. When I run this with Tomcat 8.5 and HTTPS (Http11NioProtocol), it
> works fine, uploading a file to the /tmp directory:
>
>   ...
>   protected void processRequest(HttpServletRequest request,
> HttpServletResponse response)
>       throws ServletException, IOException {
>
>     response.setContentType("text/html;charset=UTF-8");
>
>     // Create path components to save the file
>     final String path = request.getParameter("destination");
>     final Part filePart = request.getPart("file");
>     final String fileName = filePart.getSubmittedFileName();
>     ...
>
> However when I add <UpgradeProtocol
> className="org.apache.coyote.http2.Http2Protocol" /> to the <Connector> in
> servlet.xml, the servlet fails with a NullPointerException on
> filePart.getSubmittedFileName().
>
> Surprised, I tried uploading a .WAR through the Tomcat Manager with HTTP/2
> enabled. Sure enough, it failed with the message "FAIL - File upload
> failed, no file". When I track this down in the 8.5 source, I find the
> error at line #239 of org.apache.catalina.manager.HTMLManagerServlet, which
> indicates that request.getPart("deployWar") is returning null.
>
> Has anyone else seen this?
>
> I'm am running Tomcat 8.5, Java 1.8.0_91, MacOS 10.10.5, and Chrome 50.
>
> --
> "Hell hath no limits, nor is circumscrib'd In one self-place; but where we
> are is hell, And where hell is, there must we ever be" --Christopher
> Marlowe, *Doctor Faustus* (v. 121-24)
>



-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v. 121-24)