3 Replies Latest reply on Sep 20, 2018 2:32 PM by jblodgett

    Extending Wildfly, Documentation Example, Debugging The Model [Please Help]

    jblodgett

      Hi,

       

      I'm trying to create the example subsystem in the documentation.  Here is a link http://http://docs.wildfly.org/14/Extending_WildFly.html#examples-in-this

       

      I think I have made an error but I cant find my mistake after reviewing the documentation.  The two exceptions i get are:

       

      testInstallIntoController fails on "KernelServices services = super.createKernelServicesBuilder(null).build();"

       

      java.lang.AssertionError: Failed due to validation errors in the model. Please fix :-) VALIDATION ERRORS IN MODEL:Expected operation-name 'add' for operation 'add' @[

          ("subsystem" => "tracker"),

          ("type" => "*")

      ]

       

      and in a couple other tests:

       

      java.lang.IllegalArgumentException: JBAS014821: Operation contains a parameter 'tick' which is not one of the expected parameters []. {"operation" => "add","tick" => 12345L,"address" => [("subsystem" => "tracker"),("type" => "tst")]}

       

      at org.jboss.as.controller.operations.validation.OperationValidator.checkActualOperationParamsAreDescribed(OperationValidator.java:180)

      at org.jboss.as.controller.operations.validation.OperationValidator.validateOperation(OperationValidator.java:138)

      at org.jboss.as.model.test.ModelTestModelControllerService.boot(ModelTestModelControllerService.java:198)

      at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:289)

      at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:256)

      at java.base/java.lang.Thread.run(Thread.java:844)

       

      the testParseSubsystem does pass and the operations look correct.  Can anyone point me in the right direction?

       

      Regards,

      Jonathan

        • 1. Re: Extending Wildfly, Documentation Example, Debugging The Model [Please Help]
          jblodgett

          Update.  I found the mistake that was cause the first error. I had forgot to set the subsytem xml in the test.  ie KernelServices services = super.createKernelServicesBuilder(null).setSubsystemXml(subsystemXml).build();

           

          All the tests now have this error.

           

           

               java.lang.IllegalArgumentException: JBAS014821: Operation contains a parameter 'tick' which is not one of the expected parameters []. {"operation" => "add","tick" => 12345L,"address" => [("subsystem" => "tracker"),("type" => "tst")]}

          • 2. Re: Extending Wildfly, Documentation Example, Debugging The Model [Please Help]
            ctomc

            how does your model look like?

            ResourceDefintion itself?

            • 3. Re: Extending Wildfly, Documentation Example, Debugging The Model [Please Help]
              jblodgett

              Hi Tomaz, thanks for responding.

               

              my in resources/schema/acme.xsd file

               

              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 targetNamespace="urn:com.acme.corp.tracker:1.0"
                 xmlns="urn:com.acme.corp.tracker:1.0"
                 elementFormDefault="qualified"
                 attributeFormDefault="unqualified"
                 version="1.0">

               

              <!-- The subsystem root element -->
              <xs:element name="subsystem" type="subsystemType"/>

              <xs:complexType name="subsystemType">

                 <xs:all>

                 <xs:element name="deployment-types" type="deployment-typesType"/>

                 </xs:all>

              </xs:complexType>

              <xs:complexType name="deployment-typesType">

                 <xs:choice minOccurs="0" maxOccurs="unbounded">

                 <xs:element name="deployment-type" type="deployment-typeType"/>

                 </xs:choice>

              </xs:complexType>

              <xs:complexType name="deployment-typeType">

                 <xs:attribute name="suffix" use="required"/>

                 <xs:attribute name="tick" type="xs:long" use="optional" default="10000"/>

              </xs:complexType>

              </xs:schema>

               

               

              My resource Definiiton located at ./extension/TypeDefinition.java

               

              public class TypeDefinition extends SimpleResourceDefinition  implements  ResourceDefinition{

               

                 public static final TypeDefinition INSTANCE = new TypeDefinition();

               

                 //we define attribute named tick
                 protected static final SimpleAttributeDefinition TICK =

                 new SimpleAttributeDefinitionBuilder("tick", ModelType.LONG)

                .setAllowExpression(true)

                .setXmlName("tick")

                .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)

                .setDefaultValue(new ModelNode(1000))

                .setAllowNull(false)

                .build();

               

                 private TypeDefinition(){

                 super(SubsystemExtension.TYPE_PATH, SubsystemExtension.getResourceDescriptionResolver(TYPE),

                TypeAddHandler.INSTANCE,

                TypeRemoveHandler.INSTANCE);

                }

                 @Override
                 public void registerOperations(ManagementResourceRegistration resourceRegistration) {

                 super.registerOperations(resourceRegistration);

                 //you can register aditional operations here
                 }

               

                 @Override
                 public void registerAttributes(ManagementResourceRegistration resourceRegistration){

                resourceRegistration.registerReadWriteAttribute(TICK, null, TrackerTickHandler.INSTANCE);

               

               

                }

               

              }