Adam Burley
Adam Burley

Reputation: 6069

WildFly gives parse error "Unexpected element ... datasources" on startup

I'm getting a parse error when trying to start WildFly 10.1, but my standalone.xml seems valid. (I ran the whole file through an XML Validator and didn't get any errors.)

16:52:50,107 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
16:52:50,559 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
16:52:50,668 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Servlet 10.1.0.Final (WildFly Core 2.2.0.Final) starting
16:52:51,678 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.Configuratio
nPersistenceException: WFLYCTL0085: Failed to parse configuration
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131) [wildfly-controller-2.2.0.Final.jar:2.2.0.F
inal]
        at org.jboss.as.server.ServerService.boot(ServerService.java:357) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:299) [wildfly-controller-2.2.0.Final.jar:2.2.0.Final]
        at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[193,9]
Message: Unexpected element '{urn:jboss:domain:datasources:4.0}subsystem'
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108) [staxmapper-1.2.0.Final.jar:1.2.0.Final]
        at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.2.0.Final.jar:1.2.0.Final]
        at org.jboss.as.server.parsing.StandaloneXml_4.parseServerProfile(StandaloneXml_4.java:546) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.server.parsing.StandaloneXml_4.readServerElement(StandaloneXml_4.java:242) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.server.parsing.StandaloneXml_4.readElement(StandaloneXml_4.java:141) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:103) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:49) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.2.0.Final.jar:1.2.0.Final]
        at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.2.0.Final.jar:1.2.0.Final]
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123) [wildfly-controller-2.2.0.Final.jar:2.2.0.F
inal]
        ... 3 more

16:52:51,709 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messa
ges for details.
16:52:51,740 INFO  [org.jboss.as] (MSC service thread 1-3) WFLYSRV0050: WildFly Servlet 10.1.0.Final (WildFly Core 2.2.0.Final) stopped in 22ms

Here are the lines from standalone.xml starting at line 192 (end of the previous subsystem; note that the error is thrown on line 193).

    </subsystem>
    <subsystem xmlns="urn:jboss:domain:datasources:4.0">
      <datasources>
        <drivers>
          <driver module="com.mysql.jdbc" name="com.mysql.jdbc">
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
          </driver>
        </drivers>
      </datasources>
    </subsystem>
</profile>
<interfaces>

I have of course defined the module for the driver with a module.xml. But WildFly doesn't seem to actually get as far as trying to read that module.xml, as it thinks there is a parser error in standalone.xml.

I've tried changing the version from 4.0 to 2.0 or 1.2, which made no difference.

It seems WildFly is not expecting to find a subsystem element here. But there are loads of other subsystem elements in the profile element, and these don't give parsing errors.

I even tried moving the datasources subsystem element before the previous subsystem element (undertow) but this also made no difference to the outcome.

Can anyone shed any light on why it might be behaving like this?

Upvotes: 1

Views: 4308

Answers (1)

Adam Burley
Adam Burley

Reputation: 6069

I found the issue eventually. Any subsystem has its own XML namespace which must be defined in an XSD file in the \docs\schema directory under WildFly. In this case there should be a "wildfly-datasources_4_0.xsd" file, but it was missing. (My WildFly installation was seemingly based on the "servlet-only distribution" of WildFly, which doesn't include this file.) This is why there was a parse error.

Upvotes: 1

Related Questions