Solr自定义UpdateRequestProcessorFactory失败,"错误实例化UpdateRequestProcessorFactory"

时间:2015-06-14 12:38:18

标签: java solr lucene config solrcloud

我有一个自定义类扩展UpdateRequestProcessorFactory在文档添加到索引时对文档做一些工作。这在独立的Solr v4.10.3中运行良好。我移动到SolrCloud v5.2并在添加Collection(节点)时抛出此错误:

ERROR - 2015-06-14 12:25:11.071; [   docs_shard1_replica1] org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: Error CREATEing SolrCore 'docs_shard1_replica1': Unable to create core [docs_shard1_replica1] Caused by: class com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory
    at org.apache.solr.handler.admin.CoreAdminHandler.handleCreateAction(CoreAdminHandler.java:661)
    at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestInternal(CoreAdminHandler.java:213)
    at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestBody(CoreAdminHandler.java:193)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
    at org.apache.solr.servlet.HttpSolrCall.handleAdminRequest(HttpSolrCall.java:646)
    at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:417)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:227)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:196)
    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:497)
    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:745)
Caused by: org.apache.solr.common.SolrException: Unable to create core [docs_shard1_replica1]
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:651)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:611)
    at org.apache.solr.handler.admin.CoreAdminHandler.handleCreateAction(CoreAdminHandler.java:628)
    ... 27 more
Caused by: org.apache.solr.common.SolrException: Error Instantiating UpdateRequestProcessorFactory, com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory failed to instantiate org.apache.solr.update.processor.UpdateRequestProcessorFactory
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:815)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:658)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:637)
    ... 29 more
Caused by: org.apache.solr.common.SolrException: Error Instantiating UpdateRequestProcessorFactory, com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory failed to instantiate org.apache.solr.update.processor.UpdateRequestProcessorFactory
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:587)
    at org.apache.solr.core.SolrCore.createInitInstance(SolrCore.java:622)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:2281)
    at org.apache.solr.update.processor.UpdateRequestProcessorChain.init(UpdateRequestProcessorChain.java:126)
    at org.apache.solr.core.SolrCore.createInitInstance(SolrCore.java:624)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:2265)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:2259)
    at org.apache.solr.core.SolrCore.loadUpdateProcessorChains(SolrCore.java:1069)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:766)
    ... 31 more
Caused by: java.lang.ClassCastException: class com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory
    at java.lang.Class.asSubclass(Class.java:3208)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:422)
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:566)
    ... 39 more

在solrconfig.xml中我配置如下:

<updateRequestProcessorChain>
     <processor class="com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory" lib="custom-libs" version="1">
        <arr name="source">
            <str>title</str>
            <str>desc</str>
            <str>subject</str>
            <str>content</str>
        </arr>
        <str name="dest">category</str>
     </processor>
     ...
</updateRequestProcessorChain>

我试图以两种方式添加自定义jar:

  1. 将其添加到server/lib/所有Jetty个罐子所在的Error Instantiating UpdateRequestProcessorFactory文件夹中。这与.system
  2. 失败
  3. 按照建议将其添加到<processor />集合,然后使用libversion属性将其提供给Caused by: java.lang.ClassNotFoundException: com.example.solr.update.processor.SelfTaggerUpdateProcessorFactory,但Error Instantiating UpdateRequestProcessorFactorysed 's~`which cat`~/bin/cat~g' file 属性失败,$ echo '`which cat`' | sed 's~`which cat`~/bin/cat~g' /bin/cat }
  4. Dim rng as Range Set rng = Range("A2:A10") rng.Offset(0,1).Value = rng.Value 例外情况是否说明了我看不到的内容?从独立到Solrcloud的移动是否需要我错过的自定义代码?

2 个答案:

答案 0 :(得分:1)

我认为问题是从独立的Solr转向云计算。具体来说,关于使用自定义组件存储jar文件的位置。它可能对所有节点都不可见,因此失败。

但是,Solr 5.2确实具有与您可能想要使用的功能相关的新功能。假设您启用了该功能,它允许use the Config API to add the library

答案 1 :(得分:1)

问题是classloader问题。我已将自定义jar添加到server/lib/文件夹中。

当我添加Collection时,它会实例化我的自定义类,该类需要UpdateRequestProcessorFactory类,但在classloader中不可用。

我通过从server/lib/移动我的jar并将此行添加到solrconfig.xml来解决这个问题:

<lib dir="${solr.install.dir:../../..}/custom-libs/" regex="solr-.*\.jar" />

并将我的自定义jar放在custom-libs/的{​​{1}}文件夹中。这样,我确保我的自定义类仅在添加${SOLR_HOME}时加载,而不是之前加载,因此它们位于正确的Collection