commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Putnam <deput...@cisco.com>
Subject Re: [configuration] Re: CompositeConfiguration Checking Existence of Properties.
Date Wed, 31 Oct 2012 16:47:20 GMT
Hi Greg,

Not quite. I don't have any keys set yet so I don't know about the first 
line. I am only at the beginning of this and my first step was to 
determine if a property exists and if not set it. I switched back to 
using 'getString' but have the same exception. FWIW, here is the full 
traceback.

Exception in thread "main" java.lang.NullPointerException
     at
org.apache.commons.configuration.CompositeConfiguration.getProperty(CompositeConfiguration.java:261)
     at
org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(AbstractConfiguration.java:1171)
     at
org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1038)
     at
org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1021)
     at KCBSConfig.getProperty(KCBSConfig.java:21)
     at ImageTest.main(ImageTest.java:7)

Just to be sure, I added an "if (config==null) .." to my code and it 
fails that so 'config' must contain something. If this is a Java issue 
rather than misuse of CompositeConfiguration, I'm stuck.

On 10/31/2012 12:24 PM, Greg Thomas wrote:
> On 31 October 2012 16:16, Dennis Putnam<deputman@cisco.com>  wrote:
>> Thanks for the reply. I had 'getString' originally and got the same error
> So just to confirm,
>
> String foo = config.getString(keythatexists);
> String bar = config.getString(keythatdoesnotexist);
>
> is throwing a NullPointerException on the second line?
>
> If so, that sounds like a bug as it should only throw a
> NoSuchElementException - and that only if
> setThrowExceptionOnMissing(true) is called.
>
> Greg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


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


Mime
View raw message