commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arja srinivasu <srinivas...@yahoo.com>
Subject Null pointer exception while creating a XMLConfiguration object in a static method.
Date Tue, 11 May 2010 16:50:56 GMT
Hi,
I have been running into an issue while creating an xml configuration object from an xml
file, I am using jdk 1.6.0_20 and commons-configuration-1.6.jar, similar code works when the
method is non-static, appreciate any comments or pointers in resolving this issue

Here is the code which is creating this XMLConfiguration object.
privatestatic void load(String dataFilePath)throwsExceptionnull;null;   finalFile dataFile
= newFile(dataFilePath);"Data file does not exist: "+ dataFile);// this check succeeds no
assertion error is thrown"Data file is not readable: "+ dataFile);// this check succeeds no
assertion error is thrown   log.info("Reading the data file: "+ dataFile);newXMLConfiguration(dataFileURL);
{
   URL dataFileURL = 
   HierarchicalConfiguration dataFromFile = 
   assertTrue(dataFile.exists(), 
   assertTrue(dataFile.canRead(), 
   dataFileURL = ConfigurationUtils.locate(dataFilePath); //Returns a proper url of the
file passed.
   dataFromFile = 
}
 
Here is a partial stack trace of the error:

java.lang.NullPointerException
at java.net.URLDecoder.decode(Unknown Source) [na:1.6.0_20]
at java.net.URLDecoder.decode(Unknown Source) [na:1.6.0_20]
at org.apache.commons.configuration.ConfigurationUtils.fileFromURL(
at org.apache.commons.configuration.AbstractFileConfiguration.load(
at org.apache.commons.configuration.AbstractFileConfiguration.load(
at org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.load(
at org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.<init>(
at org.apache.commons.configuration.XMLConfiguration.<init>(
 
Thanks in advance.
--Srinu: nullConfigurationUtils.java:719) [commons-configuration-1.6.jar:1.6]AbstractFileConfiguration.java:276)
[commons-configuration-1.6.jar:1.6]AbstractFileConfiguration.java:193) [commons-configuration-1.6.jar:1.6]AbstractHierarchicalFileConfiguration.java:164)
[commons-configuration-1.6.jar:1.6]AbstractHierarchicalFileConfiguration.java:126) [commons-configuration-1.6.jar:1.6]XMLConfiguration.java:267)
[commons-configuration-1.6.jar:1.6]


      


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message