commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver.He...@t-online.de (Oliver Heger)
Subject Re: Configuration: init problem
Date Sun, 14 Nov 2004 18:20:03 GMT
Javier,

I think you have spotted a bug in [configuration]. Your code should work. If the file name
you provide is invalid, a ConfigurationException rather than a NullPointerException should
be thrown.

I opened a bugzilla ticket for this bug (no 32236) and will now work on a fix.

Oliver



Javier wrote:

>Hello
>
>I´ve problems with my first configuration use.
>
>I want to try to load a config file, if it fails,
>create a new one.
>
>My code is:
>
>+++++++++++++++++++++++++++++
>
>try {
>            pc = new PropertiesConfiguration("a.ini");
>
>
>        } catch (ConfigurationException ce) {
>            try {
>                pc = new PropertiesConfiguration();
>                pc.addProperty("dbClassName",
>"SQLite.JDBCDriver");
>                pc.addProperty("dbURL",
>"jdbc:sqlite://sogox.db");
>                pc.addProperty("phonesFilePath",
>"c:\\\\");
>                pc.save("a.ini");
>                
>            } catch (ConfigurationException ce1) {
>                System.err.println(ce.getMessage());
>            }
>        }
>
>++++++++++++++++++++++++++++++
>
>but, I received a error message:
>
>Exception in thread "main"
>java.lang.NullPointerException
>        at
>org.apache.commons.configuration.ConfigurationUtils.getBasePath(Confi
>gurationUtils.java:337)
>
>
>I guess it´s due to the fact that the file doesn´t
>exist and then new PropertiesConfiguration gives a
>null value.
>
>Well, my doubt is how should I do this ? which is the
>"best practice" ? should I use xml instead of
>properties ?
>
>
>Thanks in advance
>
>Javier
>
>
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Check out the new Yahoo! Front Page. 
>www.yahoo.com 
> 
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>


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


Mime
View raw message