You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2015/05/06 21:19:00 UTC

[jira] [Commented] (CONFIGURATION-600) Loading xml configuration file as a stream does not work with multi configurations

    [ https://issues.apache.org/jira/browse/CONFIGURATION-600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14531228#comment-14531228 ] 

Oliver Heger commented on CONFIGURATION-600:
--------------------------------------------

I assume you are using {{DefaultConfigurationBuilder}} for loading the file, do you? This class has a method for setting a base path. The base path is taken into account when resolving child configuration files.

You can set the base path to a URL (in string form) obtained via this.getClass().getClassLoader().getResource(). I am not sure whether this works with URLs pointing to elements in a jar file though, but you should give it a try.

> Loading xml configuration file as a stream does not work with multi configurations
> ----------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-600
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-600
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.8
>            Reporter: John Henriksson
>
> When using the commons configuration inside a WAR loading a XML file works fine when done like this:
> InputStream is = this.getClass().getClassLoader().getResourceAsStream("/conf/main.xml");
> builder.load(is);
> The problem is when the main.xml reference other xml files:
> configuration>
>     <xml fileName="child1.xml"/>
> </configuration>
> If the structure of the war is:
> /
> /classes
> /conf/child1.xml
> /conf/main.xml
> There seems to be no way to pick up child1.xml from main.xml when loading main.xml as a stream.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)