<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks for this!<div class=""><br class=""></div><div class="">The only big concern I have about this is that we’ll get this behavior for some failures but not all. And I don’t want to go down the path of trying to force every parser to work in a manner such that we consistently get this.</div><div class=""><br class=""></div><div class="">Personally I think it’s ok to have this for only some failures. Others may disagree though and start filing bug reports, leading to demands that we fix said “bugs”, leading to a shift of resource away from other tasks.</div><div class=""><br class=""></div><div class="">My instinct is it’s worth it though. I’m curious what others think.</div><div class=""><br class=""></div><div class="">I think the path you’ve followed is a good way to get a lot of benefit without being overly intrusive.</div><div class=""><br class=""></div><div class="">A medium sized concern is this has to be robust. It can’t be producing misleading messages, as that’s worse than simply pointing to the line/col of where the mistake was.</div><div class=""><br class=""></div><div class="">A minor concern is how big the added dependencies are. (I don’t know.) We want to keep WildFly Core small in footprint.</div><div class=""><br class=""></div><div class="">Re: "Only the first validation issue is reported, but this is unavoidable, since the subsystem parsers throw on the first error encountered” — I’m not bothered by that at all. We’re booting a server, not validating a document. If people are producing documents riddled with errors there are other tools to use to help with that.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 19, 2016, at 12:29 PM, Toby Crawley <<a href="mailto:tcrawley@redhat.com" class="">tcrawley@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I've done some work to pretty-print XML validation errors that occur<br class="">when parsing (standalone|domain|host).xml, and wanted to get some<br class="">feedback on what I have so far to see if:<br class=""><br class="">1) there is interest in seeing this completed<br class="">2) the current approach is the best way to integrate with WildFly<br class="">3) this same approach could be used to pretty-print issues with other<br class=""> xml parsed by WildFly (web.xml, jboss-deployment-structure.xml,<br class=""> etc)<br class=""><br class=""><br class=""># Background<br class=""><br class="">Inspired by error reporting in the Elm language[1] and improvements in<br class="">configuration feedback for Clojure tooling[2], I looked at what it<br class="">would take to provide better feedback when parsing XML configuration.<br class=""><br class="">My goals were:<br class=""><br class="">* Give users clear feedback that can be used to correct the<br class=""> configuration error without the user having to context-switch to<br class=""> documentation, and, in most cases, enable the user to quickly<br class=""> identify and understand the issue before looking away from the<br class=""> validation output, by:<br class=""><br class=""> * Showing (instead of telling) where in the XML the error occurred<br class=""><br class=""> * Providing richer feedback than the native validation error<br class=""> provides (detect potential misspellings, provide alternate<br class=""> locations, etc)<br class=""><br class=""> * Showing documentation for the element/attribute where possible<br class=""> (pulled from the XSD)<br class=""><br class="">* Use what we already produce (XSDs), without having to create<br class=""> additional context-specific schema.<br class=""><br class="">I've partially implemented a library (vdx)[3] that, given a validation<br class="">error, the source document, and the relevant schemas, generates and<br class="">prints a friendly error message. I've also made minimal changes to<br class="">WildFly to report validation errors to vdx (see below).<br class=""><br class=""><br class=""># Examples<br class=""><br class="">Below is some examples of the current startup output from WildFly when<br class="">a validation error occurs:<br class=""><br class=""><br class="">## Detecting a misspelled attribute<br class=""><br class="">13:18:03,798 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final<br class="">13:18:03,949 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final<br class="">13:18:04,010 INFO [org.jboss.as] (MSC service thread 1-6)<br class="">WFLYSRV0049: WildFly Core 2.2.0.CR5-SNAPSHOT "Kenny" starting<br class="">13:18:04,751 ERROR [org.jboss.as.controller] (Controller Boot Thread)<br class=""><br class="">====================== Validation Error in standalone.xml ======================<br class=""><br class=""> 28: <extension module="org.wildfly.extension.request-controller"/><br class=""> 29: <extension module="org.wildfly.extension.security.manager"/><br class=""> 30: <extension modue="org.wildfly.extension.undertow"/><br class=""><br class=""> ^ 'modue' isn't an allowed attribute for the<br class="">'extension' element<br class=""><br class=""> 31: </extensions><br class=""> 32: <management><br class=""> 33: <security-realms><br class=""><br class="">Did you mean 'module'?<br class=""><br class="">================================================================================<br class=""><br class=""><br class="">13:18:04,753 ERROR [org.jboss.as.server] (Controller Boot Thread)<br class="">WFLYSRV0055: Caught exception during boot:<br class="">org.jboss.as.controller.persistence.ConfigurationPersistenceException:<br class="">WFLYCTL0085: Failed to parse configuration<br class="">at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:175)<br class="">at org.jboss.as.server.ServerService.boot(ServerService.java:357)<br class="">at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:299)<br class="">at java.lang.Thread.run(Thread.java:745)<br class=""><br class="">13:18:04,754 FATAL [org.jboss.as.server] (Controller Boot Thread)<br class="">WFLYSRV0056: Server boot has failed in an unrecoverable manner;<br class="">exiting. See previous messages for details.<br class="">13:18:04,762 INFO [org.jboss.as] (MSC service thread 1-3)<br class="">WFLYSRV0050: WildFly Core 2.2.0.CR5-SNAPSHOT "Kenny" stopped in 4ms<br class=""><br class=""><br class="">## Detecting a misplaced attribute<br class=""><br class="">...<br class="">14:32:23,842 ERROR [org.jboss.as.controller] (Controller Boot Thread)<br class=""><br class="">====================== Validation Error in standalone.xml ======================<br class=""><br class=""> 89: </console-handler><br class=""> 90: <periodic-rotating-file-handler name="FILE" autoflush="true"<br class=""> 91: category="WARN"><br class=""><br class=""> ^ 'category' isn't an<br class="">allowed attribute for the 'periodic-rotating-file-handler' element<br class=""><br class=""> 92: <formatter><br class=""> 93: <named-formatter name="PATTERN"/><br class=""> 94: </formatter><br class=""><br class="">'category' is allowed on elements: subsystem > logger, subsystem ><br class="">logging-profiles > logging-profile > logger<br class="">Did you intend to put it on one of those elements?<br class=""><br class="">================================================================================<br class=""><br class="">...<br class=""><br class=""><br class="">## Detecting a misplaced element<br class=""><br class="">...<br class=""><br class="">10:54:27,359 ERROR [org.jboss.as.controller] (Controller Boot Thread)<br class=""><br class="">====================== Validation Error in standalone.xml ======================<br class=""><br class=""> 81: </management><br class=""> 82: <profile><br class=""> 83: <extension/><br class=""><br class=""> ^ 'extension' isn't an allowed element here<br class=""><br class=""> 84: <subsystem xmlns="urn:jboss:domain:logging:3.0"><br class=""> 85: <console-handler name="CONSOLE"><br class=""> 86: <level name="INFO"/><br class=""><br class="">'extension' is allowed in elements: domain > extensions, domain ><br class="">host-excludes > host-exclude > excluded-extensions, host > extensions,<br class="">host > servers > server > extensions, server > extensions<br class="">Did you intend to put it in one of those elements?<br class=""><br class="">================================================================================<br class=""><br class="">...<br class=""><br class=""><br class=""># Changes to WildFly<br class=""><br class="">To support this, I've made some small changes changes to<br class="">wildfly-core[4], but anticipate more before this is complete.<br class=""><br class="">The current changes are:<br class=""><br class="">* Modifications to ParseUtils to wrap the XMLStreamExceptions with<br class=""> an exception that can convey more context to vdx<br class="">* Modifications to XmlConfigurationPersistor to:<br class=""> * catch the wrapped exception<br class=""> * see if ${jboss.home.dir}/docs/schema/ is available. If so,<br class=""> pretty-print the error. If not, throw the wrapped exception<br class=""> (which is the behavior before my changes).<br class=""><br class=""><br class=""># Current issues<br class=""><br class="">* Only the first validation issue is reported, but this is<br class=""> unavoidable, since the subsystem parsers throw on the first error<br class=""> encountered<br class="">* This uses xmlschema-walker from Apache XmlSchema[5], which has a<br class=""> couple of bugs that will need to be fixed and released (or forked)<br class="">* Only errors reported by throwing Exceptions returned by ParseUtils<br class=""> are pretty-printed. Exceptions that come from within STAX reader<br class=""> aren't yet handled (for example, a misplaced element in the logging<br class=""> parser causes reader.handleAny() to be called[6], which triggers an<br class=""> unwrapped exception)<br class="">* vdx itself is far from complete[7] - that work is pending the<br class=""> outcome of this discussion<br class=""><br class=""><br class=""># Next steps<br class=""><br class="">As I said above, the first question to answer is: is this an<br class="">interesting feature that you would like to see completed? If so, I'm<br class="">willing to continue working on this, and would be happy to discuss<br class="">here or on JIRA/HipChat as appropriate.<br class=""><br class="">[1]: <a href="http://elm-lang.org/blog/compilers-as-assistants" class="">http://elm-lang.org/blog/compilers-as-assistants</a><br class="">[2]: <a href="http://rigsomelight.com/2016/05/17/good-configuration-feedback-is-essential.html" class="">http://rigsomelight.com/2016/05/17/good-configuration-feedback-is-essential.html</a><br class="">[3]: <a href="https://github.com/projectodd/vdx" class="">https://github.com/projectodd/vdx</a><br class="">[4]: <a href="https://github.com/tobias/wildfly-core/commit/b4d03897a6ea1b8c786d983da3b66eab0b3f36b8" class="">https://github.com/tobias/wildfly-core/commit/b4d03897a6ea1b8c786d983da3b66eab0b3f36b8</a><br class="">[5]: <a href="https://ws.apache.org/xmlschema/" class="">https://ws.apache.org/xmlschema/</a><br class="">[6]: <a href="https://github.com/wildfly/wildfly-core/blob/2.x/logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser_3_0.java#L188" class="">https://github.com/wildfly/wildfly-core/blob/2.x/logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser_3_0.java#L188</a><br class="">[7]: <a href="https://github.com/projectodd/vdx/issues" class="">https://github.com/projectodd/vdx/issues</a><br class="">_______________________________________________<br class="">wildfly-dev mailing list<br class=""><a href="mailto:wildfly-dev@lists.jboss.org" class="">wildfly-dev@lists.jboss.org</a><br class="">https://lists.jboss.org/mailman/listinfo/wildfly-dev<br class=""></div></div></blockquote></div><br class=""><div class="">
<div class=""><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1; background-color: rgb(253, 253, 253);" class="">--</span><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1; background-color: rgb(253, 253, 253);" class=""> </span><br style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1;" class=""><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1; background-color: rgb(253, 253, 253);" class="">Brian Stansberry</span><br style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1;" class=""><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1; background-color: rgb(253, 253, 253);" class="">Manager, Senior Principal Software Engineer</span><br style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1;" class=""><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; widows: 1; background-color: rgb(253, 253, 253);" class="">JBoss by Red Hat</span></div><div class=""><br class=""></div><br class="Apple-interchange-newline">
</div>
<br class=""></div></body></html>