• xml 特殊字符 导致的 solr 数据导入异常


    一、问题

    最近开发那边反应 solr 的数据好像一个月没有更新了,登陆到 solr 的服务器,查看日志,有以下的报错日志。

    org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: The reference to entity "xdm2" must end with the ';' delimiter.
    	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:220)
    	at org.apache.solr.handler.dataimport.DataImporter.maybeReloadConfiguration(DataImporter.java:130)
    	at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:175)
    	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:155)
    	at org.apache.solr.core.SolrCore.execute(SolrCore.java:2102)
    	at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:654)
    	at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:460)
    	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:257)
    	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208)
    	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
    	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
    	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    	at org.eclipse.jetty.server.Server.handle(Server.java:499)
    	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: org.xml.sax.SAXParseException; systemId: solrres:/solr-data-config.xml; lineNumber: 8; columnNumber: 206; The reference to entity "xdm2" must end with the ';' delimiter.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
    	at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:913)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:447)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
    	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:211)
    

    二、问题原因

    根据报错内容,我们查看其中的配置文件 solr-data-config.xml 发现在 password 的字段里面有个特殊字符 &, 在 xml 中 & 是特殊字符,我们需要转义它让它正常显示为 &

    三、问题解决

    我们将 & 使用 & 来替代。然后触发重新导入即可。无需重启 solr , 使用对应的 api 接口进行触发导入。

  • 相关阅读:
    BZOJ 1907: 树的路径覆盖
    BZOJ 1295: [SCOI2009]最长距离
    BZOJ 1303: [CQOI2009]中位数图
    BZOJ 1468: Tree
    BZOJ 3784: 树上的路径
    BZOJ 2006: [NOI2010]超级钢琴
    BZOJ 1831: [AHOI2008]逆序对
    BZOJ 2521: [Shoi2010]最小生成树
    HDU 6685 Rikka with Coin (枚举 思维)
    HDU 6659 Acesrc and Good Numbers (数学 思维)
  • 原文地址:https://www.cnblogs.com/operationhome/p/12240246.html
Copyright © 2020-2023  润新知