You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christoph Jaehnigen <ch...@gmail.com> on 2009/04/15 15:00:13 UTC

HTTP proxy for commons XMLConfiguration

Hi, I need some advice with the Commons Configuration library.

I use a XML file for configuration storage which has a DTD specified
being reachable by a HTTP URI. I need to use a HTTP proxy on the
executing machine.

When I try to load the XML configuration, also with setValidate() to
false I get a ConfigurationException with the message: Unable to load
the configuration. When removing the DTD statement the configuration
loads just fine.

So: is Apache commons-configuration HTTP proxy aware? Does it use the
actual JVM settings? I also tried to use the -Dhttp.proxyHost system
properties settings with no success.

So, how to do it? Btw. machine is WinXP and I'm using Eclipse as IDE
with m2eclipse for Maven support.

Thx
Chris

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


Re: HTTP proxy for commons XMLConfiguration

Posted by Oliver Heger <ol...@oliver-heger.de>.
Christoph Jaehnigen schrieb:
> Hi, I need some advice with the Commons Configuration library.
> 
> I use a XML file for configuration storage which has a DTD specified
> being reachable by a HTTP URI. I need to use a HTTP proxy on the
> executing machine.
> 
> When I try to load the XML configuration, also with setValidate() to
> false I get a ConfigurationException with the message: Unable to load
> the configuration. When removing the DTD statement the configuration
> loads just fine.
> 
> So: is Apache commons-configuration HTTP proxy aware? Does it use the
> actual JVM settings? I also tried to use the -Dhttp.proxyHost system
> properties settings with no success.
> 
> So, how to do it? Btw. machine is WinXP and I'm using Eclipse as IDE
> with m2eclipse for Maven support.
> 
> Thx
> Chris
> 

Hm, good question.

XMLConfiguration does not load the DTD on its own, but relies on the XML 
parser used. The parser itself is obtained using a default 
DocumentBuilderFactory. I would expect that the XML parser understands 
the proxy-related system variables and uses them if they are set. (Note 
that the DTD has to be loaded in any case, even if validation is 
disabled, because it might contain entity definitions that have to be 
resolved.)

For performance reasons it would be better not to load the DTD from a 
HTTP server, but ship a local copy with your application. You can put it 
somewhere on the class path. You can then use the method 
registerEntityId() of XMLConfiguration to map the public ID of the DTD 
to a local resource. That way no network access is required.

Oliver



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