Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0
-
None
-
OSX using Eclipse/Maven
Description
I have uploaded two files to HDFS.
bob.properties:
==
include=fred.properties
==
fred.properties
==
key=value
==
—
If I load fred.properties and evaluated the "key", value is returned as expected. If I load bob.properties, I get a ConfigurationException.
Here is the code snippet, please change setFileName() to reflect both cases:
FileSystem fsTest = new VFSFileSystem();
fsTest.setFileOptionsProvider(new HDFSOptionsProvider());
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.fileBased()
.setLocationStrategy(new FileSystemLocationStrategy())
.setBasePath("hdfs://localhost:8020/user/myusername")
.setFileName("bob.properties")
.setFileSystem(fsTest));
Configuration config;
try
catch (ConfigurationException e)
{ e.printStackTrace(); }--------------------
HDFSOptionsProvider.java:
==
public class HDFSOptionsProvider implements FileOptionsProvider {
@Override
public Map<String, Object> getOptions()
}
==
-------------
Here is the Exception trace:
15/08/25 14:14:46 INFO impl.StandardFileSystemManager: Using "/tmp/vfs_cache" as temporary files store.
15/08/25 14:14:47 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
org.apache.commons.configuration2.ex.ConfigurationException: Unable to load the configuration from the URL hdfs://localhost:8020/user/myusername/fred.properties
at org.apache.commons.configuration2.io.DefaultFileSystem.getInputStream(DefaultFileSystem.java:56)
at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:979)
at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:740)
at org.apache.commons.configuration2.PropertiesConfiguration.loadIncludeFile(PropertiesConfiguration.java:1419)
at org.apache.commons.configuration2.PropertiesConfiguration.propertyLoaded(PropertiesConfiguration.java:571)
at org.apache.commons.configuration2.PropertiesConfigurationLayout.load(PropertiesConfigurationLayout.java:494)
at org.apache.commons.configuration2.PropertiesConfiguration.read(PropertiesConfiguration.java:509)
at org.apache.commons.configuration2.io.FileHandler.loadFromReader(FileHandler.java:1124)
at org.apache.commons.configuration2.io.FileHandler.loadFromTransformedStream(FileHandler.java:1110)
at org.apache.commons.configuration2.io.FileHandler.loadFromStream(FileHandler.java:1049)
at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:980)
at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:963)
at org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:692)
at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initFileHandler(FileBasedConfigurationBuilder.java:312)
at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initResultInstance(FileBasedConfigurationBuilder.java:291)
at org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder.initResultInstance(FileBasedConfigurationBuilder.java:60)
at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResult(BasicConfigurationBuilder.java:421)
at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.getConfiguration(BasicConfigurationBuilder.java:285)
at com.secureops.config.TestLoadConf.main(TestLoadConf.java:33)
Caused by: java.io.IOException: VFS URLs can only be used with VFS APIs
at org.apache.commons.configuration2.io.VFSFileSystem$VFSURLStreamHandler.openConnection(VFSFileSystem.java:368)
at java.net.URL.openConnection(URL.java:975)
at java.net.URL.openStream(URL.java:1041)
at org.apache.commons.configuration2.io.DefaultFileSystem.getInputStream(DefaultFileSystem.java:52)
... 18 more