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 13:24:20 GMT
No. You would have to look at how HierarchicalConfiguration differs  
and create a patch. IIRC the problems were confined to that one class.

Ralph

On May 8, 2009, at 12:15 AM, Jonathan Su wrote:

> Hi Ralph,
>
> Thanks for the fast response! I just checked out the trunk and built  
> the
> jar, and it is indeed now saving the file successfully. Do you know  
> of any
> possible workarounds with version 1.6 release?
>
> Thanks again,
> Jonathan
>
> On Thu, May 7, 2009 at 7:14 PM, Ralph Goers <ralph.goers@dslextreme.com 
> >wrote:
>
>> 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
>>
>>


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


Mime
View raw message