[jboss-jira] [JBoss JIRA] (WFCORE-1824) Can not parse object attributes that contains a Properties attribute

Jeff Mesnil (JIRA) issues at jboss.org
Tue Sep 27 09:00:00 EDT 2016


     [ https://issues.jboss.org/browse/WFCORE-1824?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Mesnil updated WFCORE-1824:
--------------------------------
    Description: 
My resource defines an attribute which is a LIST of OBJECT that corresponds to a class (class name + module) and Properties that are passed to the created instance:

{noformat}
    private static final String CLASS = "class";
    private static final String MODULE = "module";
    public static final PropertiesAttributeDefinition PROPERTIES = new PropertiesAttributeDefinition.Builder("properties", true)
            .setAllowExpression(true)
            .build();

    public static final ObjectTypeAttributeDefinition PROCESS_STATE_LISTENER = ObjectTypeAttributeDefinition.Builder.of("process-state-listener",
            SimpleAttributeDefinitionBuilder.create(CLASS, ModelType.STRING, false)
                    .setAllowExpression(false)
                    .build(),
            SimpleAttributeDefinitionBuilder.create(MODULE, ModelType.STRING, false)
                    .setAllowExpression(false)
                    .build(),
            PROPERTIES)
            .setRestartAllServices()
            .setAllowNull(true)
            .build();
    public static final AttributeDefinition PROCESS_STATE_LISTENERS = ObjectListAttributeDefinition.Builder.of("listeners", PROCESS_STATE_LISTENER)
            .setAllowNull(false)
            .setRuntimeServiceNotRequired()
            .build();
{noformat}

I can create the resource from the CLI:

{noformat}
 /subsystem=core-management/service=process-state-listeners:add(listeners=[{class=org.foo.Listener, module=org.foo,, properties = {foo  = true, bar  = ${bar.prop:2}}}])
{"outcome" => "success"}
{noformat}

And the resource and its attribute is properly marshalled to the XML configuration:

{noformat}
            <process-state-listeners>
                <listeners>
                    <process-state-listener class="org.foo.Listener" module="org.foo">
                        <properties>
                            <property name="foo" value="true"/>
                            <property name="bar" value="${bar.prop:2}"/>
                        </properties>
                    </process-state-listener>
                </listeners>
            </process-state-listeners>
{noformat}

However the resource can not be parsed and it fails with the exception:

{noformat}
2016-09-27 14:57:35,285 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
	at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131)
	at org.jboss.as.server.ServerService.boot(ServerService.java:355)
	at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:303)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[118,25]
Message: WFLYCTL0198: Unexpected element '{urn:jboss:domain:core-management:1.0}properties' encountered
	at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:89)
	at org.jboss.as.controller.parsing.ParseUtils.requireNoContent(ParseUtils.java:244)
	at org.jboss.as.controller.AttributeParser$5.parseElement(AttributeParser.java:197)
	at org.jboss.as.controller.PersistentResourceXMLDescription.parseAttributes(PersistentResourceXMLDescription.java:208)
	at org.jboss.as.controller.PersistentResourceXMLDescription.parseAttributeGroups(PersistentResourceXMLDescription.java:140)
	at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:117)
	at org.jboss.as.controller.PersistentResourceXMLDescription.parseChildren(PersistentResourceXMLDescription.java:258)
	at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:135)
	at org.wildfly.extension.management.CoreManagementSubsystemParser_1_0.readElement(CoreManagementSubsystemParser_1_0.java:77)
	at org.wildfly.extension.management.CoreManagementSubsystemParser_1_0.readElement(CoreManagementSubsystemParser_1_0.java:50)
	at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
	at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
	at org.jboss.as.server.parsing.StandaloneXml_5.parseServerProfile(StandaloneXml_5.java:591)
	at org.jboss.as.server.parsing.StandaloneXml_5.readServerElement(StandaloneXml_5.java:245)
	at org.jboss.as.server.parsing.StandaloneXml_5.readElement(StandaloneXml_5.java:144)
	at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107)
	at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:49)
	at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
	at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
	at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
	... 3 more
{noformat}

The code in org.jboss.as.controller.AttributeParser#parseElement:197 to parse a list of objects assumes that the object's value are all represented by XML attributes. In my case, that's not correct as the "properties" attribute is represented by XML elements.

  was:
My resource defines an attribute which is a LIST of OBJECT that corresponds to a class (class name + module) and Properties that are passed to the created instance:

{noformat}
    private static final String CLASS = "class";
    private static final String MODULE = "module";
    public static final PropertiesAttributeDefinition PROPERTIES = new PropertiesAttributeDefinition.Builder("properties", true)
            .setAllowExpression(true)
            .build();

    public static final ObjectTypeAttributeDefinition PROCESS_STATE_LISTENER = ObjectTypeAttributeDefinition.Builder.of("process-state-listener",
            SimpleAttributeDefinitionBuilder.create(CLASS, ModelType.STRING, false)
                    .setAllowExpression(false)
                    .build(),
            SimpleAttributeDefinitionBuilder.create(MODULE, ModelType.STRING, false)
                    .setAllowExpression(false)
                    .build(),
            PROPERTIES)
            .setRestartAllServices()
            .setAllowNull(true)
            .build();
    public static final AttributeDefinition PROCESS_STATE_LISTENERS = ObjectListAttributeDefinition.Builder.of("listeners", PROCESS_STATE_LISTENER)
            .setAllowNull(false)
            .setRuntimeServiceNotRequired()
            .build();
{noformat}

I can create the resource from the CLI:

{noformat}
 /subsystem=core-management/service=process-state-listeners:add(listeners=[{class=org.foo.Listener, module=org.foo,, properties = {foo  = true, bar  = ${bar.prop:2}}}])
{"outcome" => "success"}
{noformat}

And the resource and its attribute is properly marshalled to the XML configuration:

{noformat}
            <process-state-listeners>
                <listeners>
                    <process-state-listener class="org.foo.Listener" module="org.foo">
                        <properties>
                            <property name="foo" value="true"/>
                            <property name="bar" value="${bar.prop:2}"/>
                        </properties>
                    </process-state-listener>
                </listeners>
            </process-state-listeners>
{noformat}

However the resource can not be parsed and it fails with the exception:

{noformat}
boss.as.server.parsing.StandaloneXml_5.readElement(StandaloneXml_5.java:144)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:49)
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
        at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
        ... 3 more

09:45:00,537 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.{noformat}

The code in org.jboss.as.controller.AttributeParser#parseElement:197 to parse a list of objects assumes that the object's value are all represented by XML attributes. In my case, that's not correct as the "properties" attribute is represented by XML elements.



> Can not parse object attributes that contains a Properties attribute
> --------------------------------------------------------------------
>
>                 Key: WFCORE-1824
>                 URL: https://issues.jboss.org/browse/WFCORE-1824
>             Project: WildFly Core
>          Issue Type: Bug
>          Components: Domain Management
>    Affects Versions: 3.0.0.Alpha8
>            Reporter: Jeff Mesnil
>            Assignee: Tomaz Cerar
>
> My resource defines an attribute which is a LIST of OBJECT that corresponds to a class (class name + module) and Properties that are passed to the created instance:
> {noformat}
>     private static final String CLASS = "class";
>     private static final String MODULE = "module";
>     public static final PropertiesAttributeDefinition PROPERTIES = new PropertiesAttributeDefinition.Builder("properties", true)
>             .setAllowExpression(true)
>             .build();
>     public static final ObjectTypeAttributeDefinition PROCESS_STATE_LISTENER = ObjectTypeAttributeDefinition.Builder.of("process-state-listener",
>             SimpleAttributeDefinitionBuilder.create(CLASS, ModelType.STRING, false)
>                     .setAllowExpression(false)
>                     .build(),
>             SimpleAttributeDefinitionBuilder.create(MODULE, ModelType.STRING, false)
>                     .setAllowExpression(false)
>                     .build(),
>             PROPERTIES)
>             .setRestartAllServices()
>             .setAllowNull(true)
>             .build();
>     public static final AttributeDefinition PROCESS_STATE_LISTENERS = ObjectListAttributeDefinition.Builder.of("listeners", PROCESS_STATE_LISTENER)
>             .setAllowNull(false)
>             .setRuntimeServiceNotRequired()
>             .build();
> {noformat}
> I can create the resource from the CLI:
> {noformat}
>  /subsystem=core-management/service=process-state-listeners:add(listeners=[{class=org.foo.Listener, module=org.foo,, properties = {foo  = true, bar  = ${bar.prop:2}}}])
> {"outcome" => "success"}
> {noformat}
> And the resource and its attribute is properly marshalled to the XML configuration:
> {noformat}
>             <process-state-listeners>
>                 <listeners>
>                     <process-state-listener class="org.foo.Listener" module="org.foo">
>                         <properties>
>                             <property name="foo" value="true"/>
>                             <property name="bar" value="${bar.prop:2}"/>
>                         </properties>
>                     </process-state-listener>
>                 </listeners>
>             </process-state-listeners>
> {noformat}
> However the resource can not be parsed and it fails with the exception:
> {noformat}
> 2016-09-27 14:57:35,285 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
> 	at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131)
> 	at org.jboss.as.server.ServerService.boot(ServerService.java:355)
> 	at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:303)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[118,25]
> Message: WFLYCTL0198: Unexpected element '{urn:jboss:domain:core-management:1.0}properties' encountered
> 	at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:89)
> 	at org.jboss.as.controller.parsing.ParseUtils.requireNoContent(ParseUtils.java:244)
> 	at org.jboss.as.controller.AttributeParser$5.parseElement(AttributeParser.java:197)
> 	at org.jboss.as.controller.PersistentResourceXMLDescription.parseAttributes(PersistentResourceXMLDescription.java:208)
> 	at org.jboss.as.controller.PersistentResourceXMLDescription.parseAttributeGroups(PersistentResourceXMLDescription.java:140)
> 	at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:117)
> 	at org.jboss.as.controller.PersistentResourceXMLDescription.parseChildren(PersistentResourceXMLDescription.java:258)
> 	at org.jboss.as.controller.PersistentResourceXMLDescription.parse(PersistentResourceXMLDescription.java:135)
> 	at org.wildfly.extension.management.CoreManagementSubsystemParser_1_0.readElement(CoreManagementSubsystemParser_1_0.java:77)
> 	at org.wildfly.extension.management.CoreManagementSubsystemParser_1_0.readElement(CoreManagementSubsystemParser_1_0.java:50)
> 	at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
> 	at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
> 	at org.jboss.as.server.parsing.StandaloneXml_5.parseServerProfile(StandaloneXml_5.java:591)
> 	at org.jboss.as.server.parsing.StandaloneXml_5.readServerElement(StandaloneXml_5.java:245)
> 	at org.jboss.as.server.parsing.StandaloneXml_5.readElement(StandaloneXml_5.java:144)
> 	at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107)
> 	at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:49)
> 	at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
> 	at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
> 	at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
> 	... 3 more
> {noformat}
> The code in org.jboss.as.controller.AttributeParser#parseElement:197 to parse a list of objects assumes that the object's value are all represented by XML attributes. In my case, that's not correct as the "properties" attribute is represented by XML elements.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list