Task: To store a file residing on Windows 7 PC in HDFS (running on Ubuntu).
Both the machines are in the same network
The following java code works without any issues outside Karaf. It copies a
file from Windows machine to the HDFS
But when I use the same code inside one of the bundle in Karaf, I get the
following exception. I am using Karaf 2.3.3. I am not able to copy file from
windows to HDFS
*Java Code:*
private void storeDataInArchive(final String archivePath, final File
source) throws Exception {
if (null != archivePath) {
UserGroupInformation ugi =
UserGroupInformation.createRemoteUser(hadoopUser);
ugi.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
LOG.info("Attempting to store data in " +
source.getName() + " HDFS store");
Configuration config = new Configuration();
config.set("fs.default.name", hadoopURL);
Path srcPath = new Path("file:///" +
source.getAbsolutePath());
Path destPath = new Path("hdfs:" + archivePath +
source.getName());
LOG.info("Source Path :" + srcPath);
LOG.info("Destination Path :" + destPath);
FileSystem destFs = destPath.getFileSystem(config);
destFs.copyFromLocalFile(srcPath, destPath);
return null;
}
});
}
else {
LOG.error("Archive Path is Null. Cannot store " +
source.getName() + " for step " + getStepID());
}
}
*Exception in Karaf Console:*
java.io.IOException: No FileSystem for scheme: hdfs
at
org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1443)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
at
org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:67)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
at
org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1464)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
at
org.apache.hadoop.fs.FileSystem.get(FileSystem.java:263)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
at
org.apache.hadoop.fs.FileSystem.get(FileSystem.java:254)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
at
org.apache.hadoop.fs.Path.getFileSystem(Path.java:187)[199:wrap_mvn_org.apache.hadoop_hadoop-core_1.2.1:0]
Could this be class dependency/Classpath issue? Please let me know what is
wrong in my Java code. Thanks in advance
--
View this message in context:
http://karaf.922171.n3.nabble.com/Working-with-Karaf-Hadoop-HDFS-tp4030617.html
Sent from the Karaf - User mailing list archive at Nabble.com.