Am 11.05.2010 21:47, schrieb arja srinivasu:
Thanks for the response, Here is the code again, hope this time it does not
appear garbled.
{
URL dataFileURL =
HierarchicalConfiguration dataFromFile =
assertTrue(dataFile.exists(), privatestatic void load(String
dataFilePath)throwsExceptionnull;null;finalFile dataFile =
newFile(dataFilePath);"Data file does not exist: "+ dataFile);dataFileURL =
ConfigurationUtils.locate(dataFilePath);
//The line below throws the error.
dataFromFile =
}
Thankslog.info("Reading the data file: "+
dataFile);newXMLConfiguration(dataFileURL);
Srinu
I still cannot read the source code, but anyway:
Because the exception happens in URLDecoder the URL returned by
ConfigurationUtils seems to be strange. Can you print it out to check
how it actually looks like?
I am not sure why you do the file to URL conversion at all. You can
directly create the XMLConfiguration passing your File object to the
constructor. Did you test this?
Oliver
----- Original Message ----
From: Oliver Heger<[email protected]>
To: Commons Users List<[email protected]>
Sent: Tue, May 11, 2010 12:27:51 PM
Subject: Re: Null pointer exception while creating a XMLConfiguration object in
a static method.
Am 11.05.2010 18:50, schrieb arja srinivasu:
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 =
}
Your code example got somehow messed up and is hardly readable. Can you
please repost?
Oliver
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: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]