Solr的4.1 DataImportHandler的ClassNotFoundException(

2019-07-19 18:21发布

我一直在试图建立数据导入处理程序(Solr的4.1)以下这个教程,并试图解决方案在先前的文章,如建议在多核Solr的配置DIH并添加dataimport罐子到类路径,但错误依然存在。 任何的方法来解决这个问题?

下面是完整的异常堆栈跟踪:

SEVERE: Unable to create core: collection1
org.apache.solr.common.SolrException: RequestHandler init failure
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:794)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:607)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:1003)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1033)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:629)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:624)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.apache.solr.common.SolrException: RequestHandler init failure
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:168)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:731)
... 13 more
Caused by: org.apache.solr.common.SolrException: Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:438)
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:507)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:581)
at    org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
... 14 more
 Caused by: java.lang.ClassNotFoundException: org.apache.solr.handler.dataimport.DataImportHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:627)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:422)
... 17 more
Feb 12, 2013 12:37:47 PM org.apache.solr.common.SolrException log
SEVERE: null:org.apache.solr.common.SolrException: Unable to create core: collection1
at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:1654)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1039)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:629)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:624)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.apache.solr.common.SolrException: RequestHandler init failure
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:794)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:607)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:1003)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1033)
... 10 more
Caused by: org.apache.solr.common.SolrException: RequestHandler init failure
at      org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:168)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:731)
... 13 more
Caused by: org.apache.solr.common.SolrException: Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:438)
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:507)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:581)
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
... 14 more
Caused by: java.lang.ClassNotFoundException: org.apache.solr.handler.dataimport.DataImportHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:627)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:422)
... 17 more

solrconfig.xml中:

    <?xml version="1.0" encoding="UTF-8" ?>
    <config>
    <luceneMatchVersion>LUCENE_41</luceneMatchVersion>
    <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
    <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
    <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
    <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
    <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
    <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
    <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
    <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
    <lib dir="../../../dist/" regex="solr-dataimporthandler-4.1.0.jar\d.*\.jar" />
    <lib dir="../../lib/" regex=".*\.jar" /> 
    <dataDir>${solr.data.dir:}</dataDir>
    <directoryFactory name="DirectoryFactory" 
        class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/> 
    <indexConfig>
    </indexConfig>
    <jmx />
    <updateHandler class="solr.DirectUpdateHandler2">
        <updateLog>
            <str name="dir">${solr.ulog.dir:}</str>
        </updateLog>
        <autoCommit> 
            <maxTime>15000</maxTime> 
            <openSearcher>false</openSearcher> 
        </autoCommit>
    </updateHandler>
    <query>
        <maxBooleanClauses>1024</maxBooleanClauses>
        <filterCache class="solr.FastLRUCache"
            size="512"
            initialSize="512"
            autowarmCount="0"/>
        <queryResultCache class="solr.LRUCache"
            size="512"
            initialSize="512"
            autowarmCount="0"/>
        <documentCache class="solr.LRUCache"
            size="512"
            initialSize="512"
            autowarmCount="0"/>
        <enableLazyFieldLoading>true</enableLazyFieldLoading>
        <queryResultWindowSize>20</queryResultWindowSize>
        <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
        <listener event="newSearcher" class="solr.QuerySenderListener">
            <arr name="queries">
            </arr>
        </listener>
        <listener event="firstSearcher" class="solr.QuerySenderListener">
            <arr name="queries">
                <lst>
                    <str name="q">static firstSearcher warming in solrconfig.xml</str>
                </lst>
            </arr>
        </listener>
        <useColdSearcher>false</useColdSearcher>
        <maxWarmingSearchers>2</maxWarmingSearchers>
    </query>
    <requestDispatcher handleSelect="false" >
        <requestParsers enableRemoteStreaming="true" 
            multipartUploadLimitInKB="2048000"
            formdataUploadLimitInKB="2048"/>
        <httpCaching never304="true" />
    </requestDispatcher>
    <requestHandler name="/select" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="echoParams">explicit</str>
            <int name="rows">10</int>
            <str name="df">app_data</str>
        </lst>
    </requestHandler>
    <requestHandler name="/query" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="echoParams">all</str>
            <str name="wt">xml</str>
            <str name="indent">true</str>
            <str name="df">app_data</str>
            <str name="spellcheck.dictionary">default</str>
            <str name="spellcheck.dictionary">wordbreak</str>
            <str name="spellcheck">on</str>
            <str name="spellcheck.extendedResults">true</str>       
            <str name="spellcheck.count">10</str>
            <str name="spellcheck.alternativeTermCount">5</str>
            <str name="spellcheck.maxResultsForSuggest">5</str>       
            <str name="spellcheck.collate">true</str>
            <str name="spellcheck.collateExtendedResults">true</str>  
            <str name="spellcheck.maxCollationTries">10</str>
            <str name="spellcheck.maxCollations">5</str>         
        </lst>
        <arr name="last-components">
            <str>spellcheck</str>
        </arr>
    </requestHandler>
    <requestHandler name="/get" class="solr.RealTimeGetHandler">
        <lst name="defaults">
            <str name="omitHeader">true</str>
            <str name="wt">json</str>
            <str name="indent">true</str>
        </lst>
    </requestHandler>
    <requestHandler name="/browse" class="solr.SearchHandler">
    </requestHandler>
    <requestHandler name="/update" class="solr.UpdateRequestHandler">
    </requestHandler>
    <requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler">
        <lst name="defaults">
            <str name="stream.contentType">application/json</str>
        </lst>
    </requestHandler>
    <requestHandler name="/update/csv" class="solr.CSVRequestHandler">
        <lst name="defaults">
            <str name="stream.contentType">application/csv</str>
        </lst>
    </requestHandler>
    <requestHandler name="/update/extract" 
        startup="lazy"
        class="solr.extraction.ExtractingRequestHandler" >
        <lst name="defaults">
            <str name="lowernames">true</str>
            <str name="uprefix">ignored_</str>
            <str name="captureAttr">true</str>
            <str name="fmap.a">links</str>
            <str name="fmap.div">ignored_</str>
        </lst>
    </requestHandler>
    <requestHandler name="/analysis/field" 
        startup="lazy"
        class="solr.FieldAnalysisRequestHandler" />
    <requestHandler name="/analysis/document" 
        class="solr.DocumentAnalysisRequestHandler" 
        startup="lazy" />
    <requestHandler name="/admin/" 
        class="solr.admin.AdminHandlers" />
    <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
        <lst name="invariants">
            <str name="q">solrpingquery</str>
        </lst>
        <lst name="defaults">
            <str name="echoParams">all</str>
        </lst>
    </requestHandler>
    <requestHandler name="/debug/dump" class="solr.DumpRequestHandler" >
        <lst name="defaults">
            <str name="echoParams">explicit</str> 
            <str name="echoHandler">true</str>
        </lst>
    </requestHandler>
    <requestHandler name="/replication" class="solr.ReplicationHandler" > 
    </requestHandler>
    <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
        <str name="queryAnalyzerFieldType">text_general</str>
        <lst name="spellchecker">
            <str name="name">default</str>
            <str name="field">keyword</str>
            <str name="classname">solr.DirectSolrSpellChecker</str>
            <str name="distanceMeasure">internal</str>
            <float name="accuracy">0.5</float>
            <int name="maxEdits">2</int>
            <int name="minPrefix">0</int>
            <int name="maxInspections">10</int>
            <int name="minQueryLength">4</int>
            <float name="maxQueryFrequency">0.02</float><!--appears in more than 2% of the documents its assumed to be correct, and no suggestions are given, I don't think use of this parameter makes any sense since dictionary is based on keyword field which is unique. Not sure if frequency is also based on that column only.-->
        </lst>
        <lst name="spellchecker">
            <str name="name">wordbreak</str>
            <str name="classname">solr.WordBreakSolrSpellChecker</str>      
            <str name="field">keyword</str>
            <str name="combineWords">true</str>
            <str name="breakWords">true</str>
            <int name="maxChanges">10</int>
        </lst>
    </searchComponent>
    <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="df">app_data</str>
            <str name="spellcheck.dictionary">default</str>
            <str name="spellcheck.dictionary">wordbreak</str>
            <str name="spellcheck">on</str>
            <str name="spellcheck.extendedResults">true</str>       
            <str name="spellcheck.count">10</str>
            <str name="spellcheck.alternativeTermCount">5</str>
            <str name="spellcheck.maxResultsForSuggest">5</str>       
            <str name="spellcheck.collate">true</str>
            <str name="spellcheck.collateExtendedResults">true</str>  
            <str name="spellcheck.maxCollationTries">10</str>
            <str name="spellcheck.maxCollations">5</str>         
        </lst>
        <arr name="last-components">
            <str>spellcheck</str>
        </arr>
    </requestHandler>
    <searchComponent name="tvComponent" class="solr.TermVectorComponent"/>
    <requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="df">app_data</str>
            <bool name="tv">true</bool>
        </lst>
        <arr name="last-components">
            <str>tvComponent</str>
        </arr>
    </requestHandler>
    <searchComponent name="clustering"
        enable="${solr.clustering.enabled:false}"
        class="solr.clustering.ClusteringComponent" >
        <lst name="engine">
            <str name="name">default</str>
            <str name="carrot.algorithm">org.carrot2.clustering.lingo.LingoClusteringAlgorithm</str>
            <str name="LingoClusteringAlgorithm.desiredClusterCountBase">20</str>
            <str name="carrot.lexicalResourcesDir">clustering/carrot2</str>
            <str name="MultilingualClustering.defaultLanguage">ENGLISH</str>
        </lst>
        <lst name="engine">
            <str name="name">stc</str>
            <str name="carrot.algorithm">org.carrot2.clustering.stc.STCClusteringAlgorithm</str>
        </lst>
    </searchComponent>
    <requestHandler name="/clustering"
        startup="lazy"
        enable="${solr.clustering.enabled:false}"
        class="solr.SearchHandler">
        <lst name="defaults">
            <bool name="clustering">true</bool>
            <str name="clustering.engine">default</str>
            <bool name="clustering.results">true</bool>
            <str name="carrot.title">name</str>
            <str name="carrot.url">id</str>
            <str name="carrot.snippet">features</str>
            <bool name="carrot.produceSummary">true</bool>
            <bool name="carrot.outputSubClusters">false</bool>
            <str name="defType">edismax</str>
            <str name="qf">
                app_data
            </str>
            <str name="q.alt">*:*</str>
            <str name="rows">10</str>
            <str name="fl">*</str>
        </lst>     
        <arr name="last-components">
            <str>clustering</str>
        </arr>
    </requestHandler>
    <searchComponent name="terms" class="solr.TermsComponent"/>
    <requestHandler name="/terms" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <bool name="terms">true</bool>
            <bool name="distrib">false</bool>
        </lst>     
        <arr name="components">
            <str>terms</str>
        </arr>
    </requestHandler>
    <searchComponent name="elevator" class="solr.QueryElevationComponent" >
        <str name="queryFieldType">string</str>
        <str name="config-file">elevate.xml</str>
    </searchComponent>
    <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
        <lst name="defaults">
            <str name="echoParams">explicit</str>
            <str name="df">app_data</str>
        </lst>
        <arr name="last-components">
            <str>elevator</str>
        </arr>
    </requestHandler>
      <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
      <str name="config">/Users/username/data-config.xml</str>
    </lst>
  </requestHandler>
    <searchComponent class="solr.HighlightComponent" name="highlight">
        <highlighting>
            <fragmenter name="gap" 
                default="true"
                class="solr.highlight.GapFragmenter">
                <lst name="defaults">
                    <int name="hl.fragsize">100</int>
                </lst>
            </fragmenter>
            <fragmenter name="regex" 
                class="solr.highlight.RegexFragmenter">
                <lst name="defaults">
                    <int name="hl.fragsize">70</int>
                    <float name="hl.regex.slop">0.5</float>
                    <str name="hl.regex.pattern">[-\w ,/\n\&quot;&apos;]{20,200}</str>
                </lst>
            </fragmenter>
            <formatter name="html" 
                default="true"
                class="solr.highlight.HtmlFormatter">
                <lst name="defaults">
                    <str name="hl.simple.pre"><![CDATA[<em>]]></str>
                        <str name="hl.simple.post"><![CDATA[</em>]]></str>
                </lst>
            </formatter>
            <encoder name="html" 
                class="solr.highlight.HtmlEncoder" />
            <fragListBuilder name="simple" 
                class="solr.highlight.SimpleFragListBuilder"/>
            <fragListBuilder name="single" 
                class="solr.highlight.SingleFragListBuilder"/>
            <fragListBuilder name="weighted" 
                default="true"
                class="solr.highlight.WeightedFragListBuilder"/>
            <fragmentsBuilder name="default" 
                default="true"
                class="solr.highlight.ScoreOrderFragmentsBuilder">
            </fragmentsBuilder>
            <fragmentsBuilder name="colored" 
                class="solr.highlight.ScoreOrderFragmentsBuilder">
                <lst name="defaults">
                    <str name="hl.tag.pre"><![CDATA[
                        <b style="background:yellow">,<b style="background:lawgreen">,
                                <b style="background:aquamarine">,<b style="background:magenta">,
                                        <b style="background:palegreen">,<b style="background:coral">,
                                                <b style="background:wheat">,<b style="background:khaki">,
                                                        <b style="background:lime">,<b style="background:deepskyblue">]]></str>
                                                            <str name="hl.tag.post"><![CDATA[</b>]]></str>
                                                    </lst>
                                                </fragmentsBuilder>
                                                <boundaryScanner name="default" 
                                                    default="true"
                                                    class="solr.highlight.SimpleBoundaryScanner">
                                                    <lst name="defaults">
                                                        <str name="hl.bs.maxScan">10</str>
                                                        <str name="hl.bs.chars">.,!? &#9;&#10;&#13;</str>
                                                    </lst>
                                                </boundaryScanner>
                                                <boundaryScanner name="breakIterator" 
                                                    class="solr.highlight.BreakIteratorBoundaryScanner">
                                                    <lst name="defaults">
                                                        <str name="hl.bs.type">WORD</str>
                                                        <str name="hl.bs.language">en</str>
                                                        <str name="hl.bs.country">US</str>
                                                    </lst>
                                                </boundaryScanner>
                                            </highlighting>
                                        </searchComponent>
                                        <queryResponseWriter name="json" class="solr.JSONResponseWriter">
                                            <str name="content-type">text/plain; charset=UTF-8</str>
                                        </queryResponseWriter>
                                        <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy"/>
                                        <queryResponseWriter name="xslt" class="solr.XSLTResponseWriter">
                                            <int name="xsltCacheLifetimeSeconds">5</int>
                                        </queryResponseWriter>
                                        <admin>
                                            <defaultQuery>*:*</defaultQuery>
                                        </admin>
                                    </config>

Answer 1:

处理任何类没有发现问题,最好的办法就是抓住所需的罐子,把他们在solr/lib目录,其中Solr的dir是相同的是包含solr.xml用来配置Solr的核心,你也需要添加以下行solrconfig.xml中

<lib dir="../lib" />

这将加载所有必需的库为您Solr的安装所有核心。

如果您需要限制罐子核心然后把它诠释

instanceDir/lib ,需要在这种情况下solrconfig.xml中任何配置。

数据导入处理工作,你将需要JDBC罐子也还有dist/solr-dataimporthandler-*.jar被放入您配置的lib目录



Answer 2:

添加lib文件夹在你的Solr的核心目录,并添加所需的lib的jar文件到这一点。 在这种情况下,你不需要指定solrconfig.xml中的文件库路径。



Answer 3:

Solr中4.1.0在工程中添加以下jar文件。
Solr的-dataimporthandler-4.1.0,Solr的-dataimporthandler-额外-4.1.0

执行它again.It会工作。



Answer 4:

我刚开始试图让Solr的4.1今天使用MySQL和遇到完全相同的问题,因为你。

我设法通过执行以下操作来解决这个问题:

  1. 注释掉所有除了一个默认的lib目录:

    <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" /> <!-- <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" /> <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" /> <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" /> <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" /> -->

  2. 抓住了最新的MySQL连接器JAR R档和Solr的dataimporthandler罐子

  3. 把他们安置在剩余的目录。

重新启动服务器和它的工作。

这是Windows 8 X86_64。

希望这可以帮助你。



Answer 5:

所选择的答案肯定是工作(这几乎可以归结为“所有内容复制到$instancedir/lib ”),但Solr的配置提供了一种方法来分离‘标准/全球性的’自带的Solr和‘延伸’库库(即定制Solr的处理程序/解析器/等),这是具体的实例。

至少有两个目录是SOLR眺望加载类需要加载:在${solr.install.dir}这是相当多的安装Solr的地方。 使用脚本(在v4.10.x可用),这是默认设置为所在目录bin/solr脚本运行。 solrconfig.xml使用该目录为基准,为加载在指定的罐子solrconfig.xml文件; 它可以通过一个java将覆盖-D参数或文件本身作为在所选择的答案指定在完全覆盖。 这是我认为一个人必须加载“全局”库。

现在,有一个第二Solr的变量${solr.solr.home}这是所有指数文物/文件被创建的实例的家,在这里我们有solr.xml 。 你有这个目录为每个Solr的实例(在不同端口上运行)分开。 在solr.xml文件,你可以有一个sharedLib元素,这是一个文件夹的相对${solr.solr.home} 。 这是我想具体的实例Solr的任何“扩展”库将被载入。



Answer 6:

我有同样的例外核心的lib文件夹。新增的Solr-dataimporthandler-额外-4.7.2.jar和Solr-dataimporthandler-4.7.2.jar。 这为我工作。



文章来源: Solr 4.1 DataImportHandler ClassNotFoundException