简体   繁体   中英

SOLR 7.4.0 exception: java.lang.NoClassDefFoundError: org/apache/solr/handler/dataimport/FieldStreamDataSource

I am trying to implement a custom SOLR FieldStreamDataSource. This is the code of my Java class:

package MySOLR;

import org.apache.solr.handler.dataimport.*;

public class MyFieldStreamDataSource extends FieldStreamDataSource {

}

My SOLR is installed in C:\\solr\\solr-7.4.0. So I added the following jar to my NetBeans project

C:\solr\solr-7.4.0\dist\solr-dataimporthandler-7.4.0.jar

and compiled it to MySOLR.jar

Then I placed MySOLR.jar into C:\\solr\\solr-7.4.0\\server\\lib\\ext and added the following to my SOLR DIH config file:

...
<dataSource name="fieldStreamDataSource" type="MySOLR.MyFieldStreamDataSource" />
...
<entity name="tika_RTF_NOTES" onError="continue" processor="TikaEntityProcessor" dataField="ts0_tika.RTF_NOTES" dataSource="fieldStreamDataSource">
    <field name="text" column="text" />
</entity>
...

I added the following entries to my SOLR core's solrconfig.xml file:

<lib dir="C:/solr/solr-7.4.0/contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="C:/solr/solr-7.4.0/dist/" regex="solr-dataimporthandler-\d.*\.jar" />
<!--lib path="C:/solr/solr-7.4.0/dist/solr-dataimporthandler-7.4.0.jar" /-->
<lib dir="C:/solr/solr-7.4.0/contrib/dataimporthandler-extras/lib" regex=".*\.jar" />
<lib dir="C:/solr/solr-7.4.0/dist/" regex="solr-dataimporthandler-extras-\d.*\.jar" />

After re-starting my SOLR instance (Windows service) I try to run the DIH via the SOLR web interface. I get the following exception in the solr.log file (and in the web interface):

2019-03-18 11:08:12.164 ERROR (qtp1986417638-24) [   x:iET] o.a.s.s.HttpSolrCall null:java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/solr/handler/dataimport/FieldStreamDataSource
        at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:662)
        at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:530)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:377)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:323)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
        ...

I am pretty sure that my entries in solrconfig.xml are correct as when I remove the entries I see that SOLR is picking up less libraries. I can see that in the solr.log file when looking at

oascSolrResourceLoader [...] Added ... libs to classloader, from paths: ...

What am I missing?

Many thanks in advance, Michael

By chance I found the solution. There are 2 alternatives (for me):

  1. Place MySOLR.jar in c:\\solr\\solr-7.4.0\\contrib\\dataimporthandler\\lib
  2. Place MySOLR.jar in c:\\solr\\solr-7.4.0\\dist and add a reference to it in solrconfig.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM