首页

解决Solr配置数据导入模块功能dataimport报DataImportHandlerException异常

标签:Apache,Dataimport,solr,数据导入,搜索,配置,apache,solr-dataimporthandler-extras,solr-dataimporthandler     发布时间:2016-07-26   

一、问题描述

最近计划将本站索引功能更换为基于Solr的搜索,想通过其配置DataImport功能将数据异步导入转换生成lucene索引文件,再通过Solr的搜索接口进行搜索,打开界面Entity框里面没有找到配置的subject实体,如下图所示,另“如何配置DataImport功能”参考更多其他页面

解决Solr配置数据导入模块功能dataimport报DataImportHandlerException异常

点击Configuration右边的Reload按钮,如下图

解决Solr配置数据导入模块功能dataimport报DataImportHandlerException异常

后台报出"ERROR org.apache.solr.core.SolrCore  – org.apache.solr.handler.dataimport.DataImportHandlerException"异常,具体如下所示

157212 [http-9998-5] INFO  org.apache.solr.handler.dataimport.DataImporter  – Loading DIH Configuration: mysql-dsmconfig.xml@b@157216 [http-9998-5] ERROR org.apache.solr.core.SolrCore  – org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: The reference to entity "characterEncoding" must end with the ';' delimiter.@b@	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:215)@b@	at org.apache.solr.handler.dataimport.DataImporter.maybeReloadConfiguration(DataImporter.java:130)@b@	at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:197)@b@	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)@b@	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1904)@b@	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:659)@b@	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:362)@b@	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)@b@	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)@b@	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)@b@	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)@b@	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)@b@	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)@b@	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)@b@	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)@b@	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)@b@	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)@b@	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)@b@	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)@b@	at java.lang.Thread.run(Thread.java:745)@b@Caused by: org.xml.sax.SAXParseException; systemId: solrres:/mysql-dsmconfig.xml; lineNumber: 3; columnNumber: 128; The reference to entity "characterEncoding" must end with the ';' delimiter.@b@	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)@b@	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)@b@	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)@b@	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)@b@	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)@b@	at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)@b@	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)@b@	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)@b@	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)@b@	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)@b@	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)@b@	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)@b@	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)@b@	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)@b@	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)@b@	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:206)@b@	... 19 more@b@@b@157217 [http-9998-5] INFO  org.apache.solr.core.SolrCore  – [subject] webapp=/xwood-solr path=/dataimport params={command=reload-config&_=1469524614856} status=500 QTime=6 @b@157217 [http-9998-5] ERROR org.apache.solr.servlet.SolrDispatchFilter  – null:org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: The reference to entity "characterEncoding" must end with the ';' delimiter.@b@	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:215)@b@	at org.apache.solr.handler.dataimport.DataImporter.maybeReloadConfiguration(DataImporter.java:130)@b@	at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:197)@b@	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)@b@	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1904)@b@	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:659)@b@	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:362)@b@	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)@b@	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)@b@	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)@b@	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)@b@	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)@b@	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)@b@	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)@b@	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)@b@	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)@b@	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)@b@	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)@b@	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)@b@	at java.lang.Thread.run(Thread.java:745)@b@Caused by: org.xml.sax.SAXParseException; systemId: solrres:/mysql-dsmconfig.xml; lineNumber: 3; columnNumber: 128; The reference to entity "characterEncoding" must end with the ';' delimiter.@b@	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)@b@	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)@b@	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)@b@	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)@b@	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)@b@	at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)@b@	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)@b@	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)@b@	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)@b@	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)@b@	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)@b@	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)@b@	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)@b@	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)@b@	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)@b@	at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:206)

二、解决步骤

1. 根据日志异常定位是配置文件mysql-dsmconfig.xml引起的,错误关键词"characterEncoding",原来内容是如下

<?xml version="1.0" encoding="UTF-8" ?>@b@<dataConfig>@b@    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8" user="root" password="root"/>@b@    <document>@b@        <entity name="subject" transformer="HTMLStripTransformer"   query="select id,title,create_time,url,keywords,zhaiyao  from pms_rep_view">@b@                <field name="id" column="id"  />@b@                <field name="title"  column="title" stripHTML="true"/>@b@        </entity>@b@    </document>@b@</dataConfig>

去除"?useUnicode=true&characterEncoding=utf-8",具体修改如下

<?xml version="1.0" encoding="UTF-8" ?>@b@<dataConfig>@b@    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/test" user="root" password="root"/>@b@    <document>@b@        <entity name="subject" transformer="HTMLStripTransformer"   query="select id,title,create_time,url,keywords,zhaiyao  from pms_rep_view">@b@                <field name="id" column="id"  />@b@                <field name="title"  column="title" stripHTML="true"/>@b@        </entity>@b@    </document>@b@</dataConfig>

2. 点击Reload按钮,重新刷新加载该mysql-dsmconfig.xml文件,问题解决了,如下图所示

解决Solr配置数据导入模块功能dataimport报DataImportHandlerException异常

解决Solr配置数据导入模块功能dataimport报DataImportHandlerException异常

<<热门下载>>