Re: [Configuration]: Classpath resource in composite configuration
On Thu, 2008-02-21 at 07:50 +, [EMAIL PROTECTED] wrote: > The following setup does not work - I was a bit disappointed. > If I load the configuration definition file off the classpath > as follows > >ConfigurationFactory factory = new ConfigurationFactory(); >URL configURL = new File("config.xml").toURL(); Hmm, not sure but you need to define the location better. As in: URL configURL = new URL("classpath://config.xml"); ...but actually I have not tested this but I reckon you get my point. salu2 >factory.setConfigurationFileName(configURL.toString()); > > and if the members of "config.xml" are presnet in the classpath: > > > > /** In > classpath **/ > > > it fails to find and load gui.xml; it yields a NullPointerException. > > Am I doing something wrong or is this indeed a limitation > of commons config? > > Tx, > > /U > -- Original message -- > From: [EMAIL PROTECTED] > > > > Guten Tag! > > > > Thanks for the prompt response. I am using ver 1.5 - I mistakenly thought > > I was using ver 1.2. > > > > Are you saying that if I load the following config defn file > > > > > > > > > > > > > > and if gui.xml can be found in classpath, would > > ConfigurationFactory.getFactory() > > automatically load gui.xml? > > > > Further, what is the precedence of loading? If gui.xml is found in > > classpath as > > well > > as in the filesystem path, would classpath take precedence? > > > > Vielen Dank! > > > > /U > > > > > > > > -- Original message -- > > From: Oliver Heger <[EMAIL PROTECTED]> > > > [EMAIL PROTECTED] schrieb: > > > > I am using commons configuration ver. 1.2. > > > > > > > > I would like ot define a composite configuration in which > > > > one or more items are classpath resources as in: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Is this somehow possible? Even if the syntax above is not supported, > > > > how can I accomplish the same result alternatively? That is, > > > > I would like to create a composite configuration in which one or more > > > > resources are loaded off the classpath. > > > > > > > > Thanks, > > > > > > > > /U > > > > > > > > > > In recent versions of commons configuration the class path is > > > automatically searched for configuration files. I am not sure whether > > > this is true for 1.2. (I guess there is a reason why you have to use > > > this old version.) > > > > > > What probably will work is to load the configuration definition file > > > itself from the class path and specify relative paths to the > > > configuration files to be loaded. If the application is correctly > > > packaged, the files should be found. > > > > > > There is also some information available at [1]. > > > > > > HTH > > > Oliver > > > > > > [1] > > > > > http://commons.apache.org/configuration/userguide-1.2/howto_configurationfactory > > > .html > > > > > > - > > > 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] > -- Thorsten Scherler thorsten.at.apache.org Open Source Java consulting, training and solutions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Configuration]: Classpath resource in composite configuration
The following setup does not work - I was a bit disappointed. If I load the configuration definition file off the classpath as follows ConfigurationFactory factory = new ConfigurationFactory(); URL configURL = new File("config.xml").toURL(); factory.setConfigurationFileName(configURL.toString()); and if the members of "config.xml" are presnet in the classpath: /** In classpath **/ it fails to find and load gui.xml; it yields a NullPointerException. Am I doing something wrong or is this indeed a limitation of commons config? Tx, /U -- Original message -- From: [EMAIL PROTECTED] > > Guten Tag! > > Thanks for the prompt response. I am using ver 1.5 - I mistakenly thought > I was using ver 1.2. > > Are you saying that if I load the following config defn file > > > > > > > and if gui.xml can be found in classpath, would > ConfigurationFactory.getFactory() > automatically load gui.xml? > > Further, what is the precedence of loading? If gui.xml is found in classpath > as > well > as in the filesystem path, would classpath take precedence? > > Vielen Dank! > > /U > > > > -- Original message -- > From: Oliver Heger <[EMAIL PROTECTED]> > > [EMAIL PROTECTED] schrieb: > > > I am using commons configuration ver. 1.2. > > > > > > I would like ot define a composite configuration in which > > > one or more items are classpath resources as in: > > > > > > > > > > > > > > > > > > > > > Is this somehow possible? Even if the syntax above is not supported, > > > how can I accomplish the same result alternatively? That is, > > > I would like to create a composite configuration in which one or more > > > resources are loaded off the classpath. > > > > > > Thanks, > > > > > > /U > > > > > > > In recent versions of commons configuration the class path is > > automatically searched for configuration files. I am not sure whether > > this is true for 1.2. (I guess there is a reason why you have to use > > this old version.) > > > > What probably will work is to load the configuration definition file > > itself from the class path and specify relative paths to the > > configuration files to be loaded. If the application is correctly > > packaged, the files should be found. > > > > There is also some information available at [1]. > > > > HTH > > Oliver > > > > [1] > > > http://commons.apache.org/configuration/userguide-1.2/howto_configurationfactory > > .html > > > > - > > 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]
Re: [Configuration]: Classpath resource in composite configuration
Guten Tag! Thanks for the prompt response. I am using ver 1.5 - I mistakenly thought I was using ver 1.2. Are you saying that if I load the following config defn file and if gui.xml can be found in classpath, would ConfigurationFactory.getFactory() automatically load gui.xml? Further, what is the precedence of loading? If gui.xml is found in classpath as well as in the filesystem path, would classpath take precedence? Vielen Dank! /U -- Original message -- From: Oliver Heger <[EMAIL PROTECTED]> > [EMAIL PROTECTED] schrieb: > > I am using commons configuration ver. 1.2. > > > > I would like ot define a composite configuration in which > > one or more items are classpath resources as in: > > > > > > > > > > > > > > Is this somehow possible? Even if the syntax above is not supported, > > how can I accomplish the same result alternatively? That is, > > I would like to create a composite configuration in which one or more > > resources are loaded off the classpath. > > > > Thanks, > > > > /U > > > > In recent versions of commons configuration the class path is > automatically searched for configuration files. I am not sure whether > this is true for 1.2. (I guess there is a reason why you have to use > this old version.) > > What probably will work is to load the configuration definition file > itself from the class path and specify relative paths to the > configuration files to be loaded. If the application is correctly > packaged, the files should be found. > > There is also some information available at [1]. > > HTH > Oliver > > [1] > http://commons.apache.org/configuration/userguide-1.2/howto_configurationfactory > .html > > - > 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]
Re: [Configuration]: Classpath resource in composite configuration
[EMAIL PROTECTED] schrieb: I am using commons configuration ver. 1.2. I would like ot define a composite configuration in which one or more items are classpath resources as in: Is this somehow possible? Even if the syntax above is not supported, how can I accomplish the same result alternatively? That is, I would like to create a composite configuration in which one or more resources are loaded off the classpath. Thanks, /U In recent versions of commons configuration the class path is automatically searched for configuration files. I am not sure whether this is true for 1.2. (I guess there is a reason why you have to use this old version.) What probably will work is to load the configuration definition file itself from the class path and specify relative paths to the configuration files to be loaded. If the application is correctly packaged, the files should be found. There is also some information available at [1]. HTH Oliver [1] http://commons.apache.org/configuration/userguide-1.2/howto_configurationfactory.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Configuration]: Classpath resource in composite configuration
I am using commons configuration ver. 1.2. I would like ot define a composite configuration in which one or more items are classpath resources as in: Is this somehow possible? Even if the syntax above is not supported, how can I accomplish the same result alternatively? That is, I would like to create a composite configuration in which one or more resources are loaded off the classpath. Thanks, /U - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]