commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Commented: (CONFIGURATION-360) java.lang.IllegalArgumentException: Passed in key must select exactly one node:
Date Fri, 23 Jan 2009 20:47:59 GMT


Oliver Heger commented on CONFIGURATION-360:

If I understand you correctly, you would like the beans defined by the {{styleDefinition}}
elements to be collected into a list and then passed to a {{setStyleDefinitions()}} method
of the window manager bean, correct?

However, {{XMLBeanDeclaration}} does not support list properties. There is currently no simple
way to achieve this I am aware of. You could create your own bean declaration class derived
from {{XMLBeanDeclaration}} and override the {{getNestedBeanDeclarations()}} method to deal
with multiple occurrences of nested elements, but this is certainly not trivial.

As is mentioned in the user guide (,
especially refer to the paragraph in italics), the mechanisms to define beans provided by
Commons Configuration are limited. If your requirements are more complex, you should think
about using a real IoC container.

> java.lang.IllegalArgumentException: Passed in key must select exactly one node:
> -------------------------------------------------------------------------------
>                 Key: CONFIGURATION-360
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: kog
>            Priority: Blocker
> I am trying to pass a list of values as parameters(Key,Vaue) in a XML file. I am trying
to pass the XML file to the XMLBeanDeclaration. It throws an error as noted below. Please
note Key is the same but values are different in the list below. 
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <config>
>   <gui>
>     <windowManager config-class=""
>       closable="false" resizable="true" defaultWidth="400"
>       defaultHeight="250">
>       <styleDefinition config-class=""
>         backColor="#ffffff" foreColor="0080ff" iconName="myicon" />
>      <styleDefinition config-class=""
>         backColor="#00000" foreColor="8888ff" iconName="youricon" />
>     </windowManager>
>   </gui>
> </config>
> I have a test configuration like this:
> private TestConfiguration(String configFile) {
>         try {
>             URL configURL = getClass().getResource("windowconfig.xml");
>             XMLConfiguration config = new XMLConfiguration(configURL);
>             BeanDeclaration decl = new XMLBeanDeclaration(config, "gui.windowManager");
>             WindowManager wm = (WindowManager) BeanHelper.createBean(decl);
>         } catch (Exception exc) {
>             throw new RuntimeException("Initialization failed", exc);
>         }
>     }
> This is the exception I am getting from the above test:
> java.lang.IllegalArgumentException: Passed in key must select exactly one node: styleDefinition

>                 at org.apache.commons.configuration.HierarchicalConfiguration.configurationAt(
>                 at org.apache.commons.configuration.HierarchicalConfiguration.configurationAt(
>                 at org.apache.commons.configuration.beanutils.XMLBeanDeclaration.getNestedBeanDeclarations(
> The HeirarchialConfiguration.configurationAt method only takes one value but not the
list of values during XMLBeanDeclaration. 
> Is there an alternative mechanism to pass a list of values? I would greatly appreciate
any help with this.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message