11

我一直在尝试按照教程设置数据导入处理程序(Solr 4.1),并尝试了以前帖子中建议的解决方案,例如在多核 solr 中配置 DIH,并将数据导入 jar 添加到类路径,但错误仍然存​​在。有什么方法可以解决这个问题?

这是整个异常堆栈跟踪:

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>
4

6 回答 6

20

处理任何类未找到问题的最佳方法是获取所需的 jar 并将它们放在solr/libdir 中,其中 solr dir 与包含用于配置 solr 核心的 solr.xml 相同,您还需要将以下行添加到 solrconfig.xml

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

这将为您的 solr 安装中的所有内核加载所有必需的库。

如果您需要将 jar 限制为核心,则将其放入 int

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

为了使数据导入处理程序正常工作,您还需要 JDBC jardist/solr-dataimporthandler-*.jar并将其放入您配置的 lib 目录中

于 2013-02-13T07:09:08.147 回答
2

在 Solr Core 目录中添加 lib 文件夹,并将所需的 lib jar 文件添加到其中。在这种情况下,您不需要在 solrconfig.xml 文件中指定 lib 路径。

于 2013-11-09T13:09:26.933 回答
1

我今天刚开始尝试让 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 jar

  3. 将它们放在剩余的目录中。

再次启动服务器,它工作。

这是在 Windows 8 X86_64 上。

希望这对您有所帮助。

于 2013-02-13T03:19:33.857 回答
1

在 solr 4.1.0 中,在项目中添加以下 jar 文件。
solr-dataimporthandler-4.1.0,solr-dataimporthandler-extras-4.1.0

再次执行它。它会工作。

于 2013-04-03T09:50:55.203 回答
0

选择的答案当然有效(这几乎可以归结为“将所有内容复制到$instancedir/lib”)但是 solr 配置提供了一种方法来分离 solr 和“扩展”库(即自定义 solr 处理程序/解析器)附带的“标准/全局”库/etc) 特定于实例。

至少有两个目录需要 solr 来加载类需要加载:${solr.install.dir}这几乎是 solr 的安装位置。使用脚本(在 v4.10.x 中可用)默认设置bin/solr为运行脚本的目录。 solrconfig.xml使用此目录作为加载solrconfig.xml文件中指定的 jar 的基础;它可以被 java-D参数覆盖或在文件本身中完全覆盖,如所选答案中指定的那样。这是我认为必须加载“全局”库。

现在,有一个第二个 solr 变量${solr.solr.home},它是创建所有索引工件/文件的实例主页,这里我们有solr.xml. 您分别为每个 solr 实例(在不同的端口中运行)拥有此目录。在该solr.xml文件中,您可以有一个sharedLib元素,它是一个文件夹 relative ${solr.solr.home}。这是我认为将加载特定于 solr 实例的任何“扩展”库。

于 2015-01-13T16:14:06.490 回答
0

我有同样的例外 .add solr-dataimporthandler-extras-4.7.2.jar 和 solr-dataimporthandler-4.7.2.jar 在你的核心的 lib 文件夹中。这对我有用。

于 2015-03-19T16:29:06.670 回答