Skip to content

schemaGen generates XSD schemas with missing attributes for onError type elements #34057

@jimblye

Description

@jimblye

Describe the bug
The schemaGen command-line utility generates invalid XSD schemas for Liberty server configuration. Configuration attributes with onError type generate malformed XSD elements that are missing required attributes, resulting in invalid schemas that cannot be used for validation. The specific problem varies by schema output version:

For schema version 1 (--outputVersion=1 or default):

Missing base="xsd:string" attribute in xsd:restriction elements
Generated XSD:

<xsd:attribute name="onError">
  <xsd:simpleType>
    <xsd:restriction>  <!-- MISSING base="xsd:string" -->
      <xsd:enumeration value="WARN"/>
      ...
    </xsd:restriction>
  </xsd:simpleType>
</xsd:attribute>

For schema version 2 (--outputVersion=2):

Missing memberTypes="variableType" attribute in xsd:union elements
Generated XSD:

<xsd:attribute name="onError">
  <xsd:simpleType>
    <xsd:union>  <!-- MISSING memberTypes="variableType" -->
      <xsd:simpleType>
        <xsd:restriction>  <!-- MISSING base="xsd:string" -->
           <xsd:enumeration value="WARN"/>
          ...
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:union>
  </xsd:simpleType>
</xsd:attribute>

Steps to Reproduce
For version 1 schemas:

  1. Run: bin/schemaGen (or bin/schemaGen --outputVersion=1)
  2. Open the generated usr/servers/defaultServer/server.xsd
  3. Search for onError attributes
  4. Observe xsd:restriction elements are missing the base attribute

For version 2 schemas:

  1. Run: bin/schemaGen --outputVersion=2
  2. Open the generated usr/servers/defaultServer/server.xsd
  3. Search for onError attributes
  4. Observe xsd:union elements are missing the memberTypes attribute

Expected behavior
For schema version 1:

<xsd:attribute name="onError">
  <xsd:simpleType>
    <xsd:restriction base="xsd:string">  <!-- base attribute required -->
      <xsd:enumeration value="WARN"/>
      <xsd:enumeration value="FAIL"/>
      <xsd:enumeration value="IGNORE"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:attribute>

For schema version 2:

<xsd:attribute name="onError">
  <xsd:simpleType>
    <xsd:union memberTypes="variableType">  <!-- memberTypes attribute required -->
      <xsd:simpleType>
        <xsd:restriction base="xsd:string">
          <xsd:enumeration value="WARN"/>
          <xsd:enumeration value="FAIL"/>
          <xsd:enumeration value="IGNORE"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:union>
  </xsd:simpleType>
</xsd:attribute>

Diagnostic information:

  • OpenLiberty Version: all
  • Affected feature(s): schemaGen utility
    Java Version: N/A
    Commands affected: bin/schemaGen and bin/schemaGen --outputVersion=2

Additional context
The problem has been showing up for years now in ifix builds, as unit test failures:

> Task :com.ibm.ws.config.schemagen:test FAILED

Generatorv1WithSchema10Test > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv1WithSchema10Test > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv1WithSchema11Test > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv1WithSchema11Test > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchema10Test > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchema10Test > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchema11Test > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchema11Test > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchmea11BetaBuildTest > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchmea11BetaBuildTest > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchmea11GABuildTest > checkEnumeration FAILED
    org.junit.ComparisonFailure at Assert.java:125

Generatorv2WithSchmea11GABuildTest > checkOnErrorType FAILED
    org.junit.ComparisonFailure at Assert.java:125

SchemaGenTest > testSchemaGenNoParms FAILED
    java.lang.AssertionError at SchemaGenTest.java:298

SchemaGenTest > testSchemaGenHelp FAILED
    java.lang.AssertionError at SchemaGenTest.java:324

SchemaGenTest > testSchemaGenOutput FAILED
    java.lang.AssertionError at SchemaGenTest.java:357
Test counts so far:
208 total tests
193 total passing
15 total failing
0 total skipped

The bottom 3 test failures are unrelated to the problem. Those are caused by a missing message bundle. I tested those manually in a released driver and they work fine. So those 3 failures seem like an environmental issue.

Metadata

Metadata

Assignees

Labels

release bugThis bug is present in a released version of Open Liberty

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions