Error when start Solr cloud, due to location of 3r

2019-03-16 17:30发布

问题:

I tried to migrate to Solr 3.1 , my project uses Dataimport handler , when I started solr it asked me SolrCoreAwar not found I copied the following file to lib directory apache-solr-dataimporthandler-3.1-SNAPSHOT.jar but again an error appeared when stating solr I need to fix this problem , if you can help Thank You

The next message is the exception I get When Starting Solr 3.1

 java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.LoggerFactory
    at org.apache.solr.handler.dataimport.DataImportHandler.<clinit>(DataImportHandler.java:72)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:373)
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:423)
    at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:459)
    at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:563)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:458)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:207)
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:130)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.mortbay.start.Main.invokeMain(Main.java:194)
    at org.mortbay.start.Main.start(Main.java:534)
    at org.mortbay.start.Main.start(Main.java:441)
    at org.mortbay.start.Main.main(Main.java:119

Update

I've added the following jar files to my class path , the previous exception disappeared , but a new Error appeared when starting solr server :

 Error Instantiating Request Handler, org.apache.solr.handler.dataimport.DataImportHandler is not a org.apache.solr.request.SolrRequestHandler
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:425)
    at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:459)
    at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:563)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:458)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:207)
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:130)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.mortbay.start.Main.invokeMain(Main.java:194)
    at org.mortbay.start.Main.start(Main.java:534)
    at org.mortbay.start.Main.start(Main.java:441)
    at org.mortbay.start.Main.main(Main.java:119)

回答1:

The problem is now solved.

This problem occurred because dataimporthandler and requesthandler are loaded by two different class loaders. To solve it, ensure that solr loads its jars only from the same class loader.

First of all I ensured that :

1) In solrconfig.xml remove ensure that dataimporthandler only comes from one place 2) I have commented all directives and added new one that refers to lib directory in solr directory so the lib directory path is example/solr/lib , this directory doesn't exists by default. Create it (for example using mkdir solr/lib) and the lib directive in solrconfig.xml becomes

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

3) Add the jar file from dist directory to this directory example/solr/lib
4) Fire up your solr server

And don't forget to copy your mysql-driver jar to your include path to be able to index your mysql database tables if you use dataimporthandler for this purpose

Note: This works for solr 4.0



回答2:

The problem is most probably deeper, but you could try putting slf4j apis in your class path. (http://www.slf4j.org/download.html).



回答3:

@see SOLR-2574 for a solution and sample working project. It's for Solr 3.2 but it works with Sorl 3.1 too.

In short, add a dependency on slf4j-nop.

   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-nop</artifactId>
      <version>1.6.1</version>
    </dependency>


回答4:

A couple of months later, you may get the response.

Had the exact same issue and I was able to get over it by actually using absolute paths to the data import handler.



回答5:

#solr 3.5 : The classloader issue has been correctly identified above, but the solution didn't seem to work for me. I just put the dataimporthandler jars into the solr.war file and that worked, of course.