The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

HDFS Forum

WebHDFS error when upload file

  • #24880


    I’m getting the following error message when I upload a File to HDFS using WebHDFS that has spaces on it, (no spaces works great):

    I’m basically using URLEncode for the path of the HTTP request, the Namenode seems to accept this but getting error when make the second Request (PUT) to the Datanode from the initial redirect of the Namenode.

    Am I missing something?

    2013-05-08 09:57:52,989 ERROR PriviledgedActionException as:hdfs Illegal character in path at index 51: webhdfs://HadoopMaster.demo.vm:50070/usr/UT/File1MB (1).txt
    2013-05-08 09:57:52,989 WARN org.apache.hadoop.hdfs.web.resources.ExceptionHandler: INTERNAL_SERVER_ERROR
    java.lang.reflect.UndeclaredThrowableException: Unknown exception in doAs
    at org.apache.hadoop.hdfs.server.datanode.web.resources.DatanodeWebHdfsMethods.put(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    Caused by: Illegal character in path at index 51: webhdfs://HadoopMaster.demo.vm:50070/usr/UT/File1MB (1).txt
    at Method)
    … 40 more
    Caused by: Illegal character in path at index 51: webhdfs://HadoopMaster.demo.vm:50070/usr/UT/File1MB (1).txt
    at org.apache.hadoop.hdfs.server.datanode.web.resources.DatanodeWebHdfsMethods$
    at org.apache.hadoop.hdfs.server.datanode.web.resources.DatanodeWebHdfsMethods$
    … 43 more

  • Author
  • #24881

    Here is the Request/Response sequence:
    PUT http://hadoopmaster.demo.vm:50070/webhdfs/v1/usr/UT/File1MB%20(1).txt? HTTP/1.1
    Host: hadoopmaster.demo.vm:50070
    Content-Length: 0

    Content-Type: application/octet-stream
    Expires: Thu, 01-Jan-1970 00:00:00 GMT
    Set-Cookie: hadoop.auth=”u=hdfs&p=hdfs&t=simple&e=1368061072186&s=S8h6fTDohs5HZ8Uanm/ghaFGavs=”;Path=/
    Location: http://HadoopNode1.demo.vm:50075/webhdfs/v1/usr/UT/File1MB%20(1).txt?op=CREATE&
    Content-Length: 0
    Server: Jetty(6.1.26)
    PUT http://hadoopnode1.demo.vm:50075/webhdfs/v1/usr/UT/File1MB%20(1).txt?op=CREATE& HTTP/1.1
    Host: hadoopnode1.demo.vm:50075
    Content-Length: 1050626
    Expect: 100-continue

    HTTP/1.1 500 Internal Server Error
    Content-Type: application/json
    Transfer-Encoding: chunked
    Server: Jetty(6.1.26)

    {“RemoteException”:{“exception”:”UndeclaredThrowableException”,”javaClassName”:”java.lang.reflect.UndeclaredThrowableException”,”message”:”Unknown exception in doAs”}}

    Seth Lyubich

    Hi Ramiro,

    We were able to reproduce this. What is interesting is that we can actually see and read file from command line even though WebHDFS exception happened during put. Can you please check to see if you actually can read file from command line after this exception occurred?



    Hi Seth, yes i can read the file using command line, the file seems to be saved correctly, I can even download it using webHDFS, it just the error code from the request that comes back. Not sure what is happening, also not sure if the file integrity is correct among the cluster. I test with a small file.


    Hi Ramiro,

    Have you tried escaping the spaces with ‘\’ ?



    Hi tedr,

    I have tried escaping spaces with ‘\’, and it looks like the file name now is correct on the HDFS, however I got the file in a sub folder and I still have an Internal Server error response from the HDFS, but there is no error on the NameNode.log.

    for example
    http://Namenode:50070/usr/UT/File1MB 1.txt – > http://Namenode:50070/usr/UT/File1MB\ 1.txt
    and I ended up having the file under a File1MB subfolder with a file name 1.txt

    # hadoop fs -ls /usr/UT/File1MB/
    Found 1 items
    -rw-r–r– 3 hdfs hdfs 1050626 2013-05-10 13:30 /usr/UT/File1MB/ 1.txt.tmp

    However I think the escape shouldn’t be done by the client, but the Hadoop name node, since HTTP web request have standards and RFC when it comes to URI and URL encoding handling .

    So my question for you guys is:
    Are you guys going to create a Issue so it can be fix in future versions? is there is a workaround I can use.

    Let me know and also let me know there is anything else I can help. cheers.


    Hi Ramiro,

    Yes we will log an issue for this, after making sure it’s not already there. Also I will continue to look for a workaround and will get back to you when I find one.


The forum ‘HDFS’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.