commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete Cain <pete...@gmail.com>
Subject Re: [Configuration] ConfigurationFactory resources from classpath/jar.
Date Tue, 12 Apr 2005 08:21:08 GMT
To answer my own post and stop anyone wasting time on this.  Looks to
me like a bona fide bug in AbstractFileConfiguration.

AbstractFileConfiguration(String) calls set path which creates a File
and breaks the string into basePath and fileName components.  Then
load() occurs load occurs calling ConfigurationUtils.locate(basePath,
fileName).  ConfigrationsUtils.locate(String, String) only uses
fileName when looking for the resource on the system or context
classpaths.

I'll stick this in bugzilla soon.

On Apr 12, 2005 5:58 PM, Pete Cain <petec33@gmail.com> wrote:
> Oliver,
> 
> Thanks for that, I read that part but it seems there is a bug somewhere because.
> 
> If I do this
> PropertiesConfiguration("example/package/configuration/application-version.properties");
> I get an exception:
> org.apache.commons.configuration.ConfigurationException: Cannot locate
> configuration source application-version.properties
>         at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:183)
> ...
> (Its odd that it doesn't report the whole url)
> 
> If I do this
> URL url = ConfigurationUtils.locate(null,
> "example/package/configuration/application-version.properties");
> 
> I get a non null URL refrenece that points to the correct location
> 
> If I do this
> PropertiesConfiguration test = new PropertiesConfiguration();
> test.setFileName("example/package/configuration/application-version.properties");
> test.load();
> 
> The Configurations loads and I can access the values.
> 
> Give this behaviour it makes sense that using ConfigurationFactory
> didn't work as expected.
> 
> I have looked thru bugzilla and I haven't found any open bugs that
> seem to relate to this.  I've just started to look thru the source.
> 
> But any further suggestions on what could be causing this would be
> greatly appreciated.
> 
> Pete
> 
> On Apr 12, 2005 3:58 PM, Oliver Heger <hegero@med.uni-marburg.de> wrote:
> > Pete,
> >
> > version 1.1 of commons-configuration already supports loading
> > configuration files from the classpath. More information about this
> > subject is available here:
> > http://jakarta.apache.org/commons/configuration/howto_properties.html
> > (in the section called "Loading").
> >
> > Oliver
> >
> > Pete Cain wrote:
> > > Hi,
> > >
> > > What I'm aiming to do is use commons-configuration to load a bunch of
> > > configuration data from with in a jar that forms my default
> > > configuration and then load anything runtime modified configurations
> > > afterwards.
> > >
> > > My problems so far have been with loading configurations as resources
> > > from the class path.  To do this I have customized the digester rules
> > > use by ConfigurationFactory to give me a <properties-as-resource> tag.
> > >  The digester rule specifies a class that extends
> > > PropertiesConfiguration and overrides load(String fileName) so that
> > > the file name is always loaded using getClass().getResource(String).
> > > I have found this approach to work so far.
> > >
> > > What I'd like to know is, am I on the right track with this ?
> > > Considering I've only just started investigating commons-configuration
> > > are there any problems I could run into in using the approach ?
> > >
> > > Thanks in advance
> > >
> > > Pete
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
> >
> > --
> > Dipl.-Inform. Oliver Heger
> > Zentrale Informationsverarbeitung (ZIV) / Bereich Anwenderverfahren
> > Klinikum der Philipps-Universität Marburg
> > Baldingerstraße,
> > D-35037 Marburg
> > Tel: +49 6421 28-66679
> > mailto:oliver.heger@med.uni-marburg.de
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> 
> --
> bludja.blogspot.com
>

---------------------------------------------------------------------
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