Received non-all-whitespace CHARACTERS or CDATA event in nextTag(). ,无法整齐打印验证错误。 解析XML文档出现的问题

在启动keyCloak,想要在standAlone模式下切换数据库,修改standAlone.xml文件时。

在bin/目录下启动standAlone模式出现错误:

10:07:24,799 INFO  [org.jboss.as.controller] (Controller Boot Thread) OPVDX002:无法整齐打印验证错误:null
10:07:24,800 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:143)
        at org.jboss.as.server.ServerService.boot(ServerService.java:377)
        at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:372)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.xml.stream.XMLStreamException: com.ctc.wstx.exc.WstxParsingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag().
at [row,col {unknown-source}]: [141,7]
        at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:650)
        at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:204)
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:122)
        at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
        at org.jboss.as.server.parsing.StandaloneXml_7.parseServerProfile(StandaloneXml_7.java:607)
        at org.jboss.as.server.parsing.StandaloneXml_7.readServerElement(StandaloneXml_7.java:240)
        at org.jboss.as.server.parsing.StandaloneXml_7.readElement(StandaloneXml_7.java:137)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:117)
        at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:52)
        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:122)
        at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:76)
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:126)
        ... 3 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag().
at [row,col {unknown-source}]: [141,7]
        at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:621)
        at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:491)
        at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:475)
        at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1224)
        at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.nextTag(XMLExtendedStreamReaderImpl.java:152)
        at org.jboss.as.connector.subsystems.datasources.DsParser.parseDataSource_4_0(DsParser.java:1927)
        at org.jboss.as.connector.subsystems.datasources.DsParser.parseDataSources(DsParser.java:229)
        at org.jboss.as.connector.subsystems.datasources.DsParser.parse(DsParser.java:189)
        at org.jboss.as.connector.subsystems.datasources.DataSourcesExtension$DataSourceSubsystemParser.readElement(DataSourcesExtension.java:643)
        ... 14 more

10:07:24,803 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
10:07:24,820 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0050: Keycloak 4.4.0.Final (WildFly Core 5.0.0.Final) stopped

 

 

  这是standalone.xml的文件配置:

   <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" use-java-context="true">
                        <connection-url>jdbc:mysql://localhost:3306/keycloak?useSSL=false&tcpRcvBuf=102400000</connection-url>
                        <driver-class>com.mysql.jdbc.Driver</driver-class>    
                        <driver>mysql</driver>
                        <security>
                            <user-name>root</user-name>
                            <password>root</password>
                        </security>
                        <!--增加验证信息      -->
                <!--            <validation>
                               <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                               <background-validation>true</background-validation>
                               <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                            </validation>
                            -->
                </datasource>


                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="mysql" module="com.mysql">
                    <!-- <driver-class>com.mysql.jdbc.Driver</driver-class>      -->
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
发现问题:
1.认为是我的url-connection 写的有问题,不断地修改。
2.找到文件夹modules\system\layers\base\com\mysql\main    下的module 和mysql-connector-java.5.1.40jar
不断修改JAR包的版本和modules.xml地配置。
3.询问同事:一开始以为是字符集编码的问题,但是后面发现了at [row,col {unknown-source}]: [141,7]这个地方出现了问题。
从此打开了自己的认知大门:发现了自己一开始的问题所在,而我却忽略他了:
 
在修改standalone.xml时,在edit-plus出现如下页面。
 

问题原因:

从下图可以看到,因为不同编码方式的空格占位符不同,比如在ANSI编码里面,空格占用一个字符 ,但是在UTF-8里面,可能占用的是2个字符。
于是在Edit-plus中编辑的时候,出现以上情况的报错。  从而造成无法解析xml的情况。

 

 
解决途径:
1.手敲代码,
2.从其他博客中复制过来的代码,单行复制!单行复制!单行复制!
 
总结:今后从其他博客中复制过来的代码一定要提前检查各种问题,已经有很多次遇到这种情况:复制他人的代码,结果不断报错。   今后复制粘贴的时候要留个心眼。
 
 

 

posted @ 2019-01-17 13:20  吃土豆鸭  阅读(1955)  评论(0编辑  收藏  举报