commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [Commons Configuration] Saving a CombinedConfiguration with ViewNodes
Date Fri, 08 May 2009 02:14:52 GMT
Actually, I take it back. I think I already fixed this. Can you check  
out trunk and see if you still have the same problem?

Ralph

On May 7, 2009, at 5:00 PM, Jonathan Su wrote:

> Hi,
>
> I am using the CombinedConfiguration class to combine two  
> XMLConfigurations
> and trying to save the result as xml. My code is as follows:
>
>                CombinedConfiguration cc = new  
> CombinedConfiguration(new
> OverrideCombiner());
>                cc.addConfiguration(firstXMLConfig);
>                cc.addConfiguration(secondXMLConfig);
>                combinedConfig = new XMLConfiguration(cc);
>                combinedConfig.save("path/to/file.xml");
>
> When I try to do the save operation however, I am getting the  
> following
> exception:
>
> Caused by: java.lang.ClassCastException:
> org.apache.commons.configuration.tree.ViewNode cannot be cast to
> org.apache.commons.configuration.HierarchicalConfiguration$Node
>    at
> org.apache.commons.configuration.HierarchicalConfiguration 
> $BuilderVisitor.visitBeforeChildren(HierarchicalConfiguration.java: 
> 1624)
>    at
> org.apache.commons.configuration.HierarchicalConfiguration 
> $Node.visit(HierarchicalConfiguration.java:1329)
>    at
> org.apache.commons.configuration.XMLConfiguration 
> $XMLBuilderVisitor.processDocument(XMLConfiguration.java:1321)
>    at
> org 
> .apache 
> .commons 
> .configuration.XMLConfiguration.createDocument(XMLConfiguration.java: 
> 759)
>    at
> org 
> .apache 
> .commons.configuration.XMLConfiguration.save(XMLConfiguration.java: 
> 878)
>    at
> org 
> .apache.commons.configuration.AbstractHierarchicalFileConfiguration 
> $ 
> FileConfigurationDelegate 
> .save(AbstractHierarchicalFileConfiguration.java:454)
>    at
> org 
> .apache 
> .commons 
> .configuration 
> .AbstractFileConfiguration.save(AbstractFileConfiguration.java:546)
>    at
> org 
> .apache 
> .commons 
> .configuration 
> .AbstractFileConfiguration.save(AbstractFileConfiguration.java:513)
>    at
> org 
> .apache 
> .commons 
> .configuration 
> .AbstractFileConfiguration.save(AbstractFileConfiguration.java:491)
>    at
> org 
> .apache 
> .commons 
> .configuration 
> .AbstractFileConfiguration.save(AbstractFileConfiguration.java:403)
>    ... 26 more
>
> It looks like ViewNode is created when firstXMLConfig and  
> secondXMLConfig
> have a node with the same key in the combine process. Is there a way  
> to
> convert all ViewNodes into HierarchicalConfiguration.Node? Or am I  
> using
> this incorrectly?
>
> Thanks,
> Jonathan


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


Mime
View raw message