You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by ying lcs <yi...@gmail.com> on 2007/08/12 08:56:51 UTC

how to use XML Configuration of Jakarta Commons in a servlet?

Hi,

I am trying to use XMLConfiguration in my servlet like this:

try {
			xmlconfig = new XMLConfiguration("config.xml");
		} catch (ConfigurationException  e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

But it can't load the file 'config.xml'. Can you please tell me where
should I put the config.xml file so that it can load it?

org.apache.commons.configuration.ConfigurationException: Cannot locate
configuration source config.xml
	at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:213)
	at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:193)
	at org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.load(AbstractHierarchicalFileConfiguration.java:163)
	at org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.<init>(AbstractHierarchicalFileConfiguration.java:90)
	at org.apache.commons.configuration.XMLConfiguration.<init>(XMLConfiguration.java:169)
	at  com.mytest.myservlet.ServletConfig.<clinit>(ServletConfig.java:39)

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


Re: how to use XML Configuration of Jakarta Commons in a servlet?

Posted by Billy Bacon <bi...@gmail.com>.
If you want to use the below code as is, you will need to put the
config.xml in the same package (directory) as the .java file which
contains the code below so the classloader can find it.

- Billy -


On 8/12/07, ying lcs <yi...@gmail.com> wrote:
> Hi,
>
> I am trying to use XMLConfiguration in my servlet like this:
>
> try {
> 			xmlconfig = new XMLConfiguration("config.xml");
> 		} catch (ConfigurationException  e) {
> 			// TODO Auto-generated catch block
> 			e.printStackTrace();
> 		}
>
> But it can't load the file 'config.xml'. Can you please tell me where
> should I put the config.xml file so that it can load it?
>
> org.apache.commons.configuration.ConfigurationException: Cannot locate
> configuration source config.xml
> 	at
> org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:213)
> 	at
> org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:193)
> 	at
> org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.load(AbstractHierarchicalFileConfiguration.java:163)
> 	at
> org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.<init>(AbstractHierarchicalFileConfiguration.java:90)
> 	at
> org.apache.commons.configuration.XMLConfiguration.<init>(XMLConfiguration.java:169)
> 	at  com.mytest.myservlet.ServletConfig.<clinit>(ServletConfig.java:39)
>
> ---------------------------------------------------------------------
> 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