lucky_start_izumi
lucky_start_izumi

Reputation: 2591

Illegal character in authority at index 7: hdfs://localhost:9000 with hadoop

I am trying to connect to hdfs.

Configuration configuration = new Configuration();
configuration.set("fs.default.name", this.hdfsHost);
fs = FileSystem.get(configuration);

hdfsHost is 127.0.0.1:9000.

but get this exception at FileSystem.get();

I have another project running the same code, but works well. Could anyone give any suggestion? Thank you very much

the exception track:

Exception in thread "main" java.lang.IllegalArgumentException
at java.net.URI.create(URI.java:842)
at org.apache.hadoop.fs.FileSystem.getDefaultUri(FileSystem.java:103)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:95)
at TransferToHadoop.TransferFiles.<init>(TransferFiles.java:50)             
at.TransferToHadoop.ScheduleTransferJobs.getTransferFiles(ScheduleTransferJobs.java:99)
at .TransferToHadoop.ScheduleTransferJobs.main(ScheduleTransferJobs.java:30)
 Caused by: java.net.URISyntaxException: Illegal character in authority at index 7: hdfs://localhost:9000  
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.parseAuthority(URI.java:3147)
at java.net.URI$Parser.parseHierarchical(URI.java:3058)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
at java.net.URI.create(URI.java:840)
... 5 more

Upvotes: 1

Views: 17792

Answers (3)

Binita Bharati
Binita Bharati

Reputation: 5898

This can happen if there is trailing space in the core-site.xml against the property value for hdfs name (fs.defaultFS).

Upvotes: 3

Saroj
Saroj

Reputation: 1

Bind the host name with the corresponding ip in both the servers i.e. in both client and server in /etc/hosts file

Upvotes: 0

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

Try passing hdfsHost as a qualified url hdfs://127.0.0.1:9000 instead of 127.0.0.1:9000

Upvotes: 3

Related Questions