Question

I'm trying to set up Solr 3.5.0 on JBoss 5.1. Everything works quite fine. I copied war into deploy dir, all the dependencies from dist and contrib directories into the lib (or earlier deploy) directory.

I can start a server, everything works fine, but whenever I want to activate the DataImportHandler to index data in my DB, I get an error.

Basically what I do is I copy is I copy a core from example/example-DIH/solr/db (Or whole example, that doesn't matter), I register the core in solr.xml and at startup I get an error:

15:17:10,707 SEVERE [RequestHandlers] org.apache.solr.common.SolrException: 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:427)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:461)
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:157)

I'm pretty sure my request handler definition is correct, but just to be sure:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
  <str name="config">dataimport.xml</str>
</lst>

As far as I can find, this error may be caused by DataImportHandler and SolrRequestHandler supposedly being hold different class loaders.

Whenever I start a Solr from the start.jar app in example (I think it starts a Jetty server) it works fine.

My question is: is this really because of the class loader issue, or some other thing? And, more importantly: how do I fix it?

Was it helpful?

Solution

This is a class loader issue and according to this post on the Lucene Developer Mailing List you need to do the following:

make sure that the dataimport jars are NOT in the classpath and not loaded by other classloaders but from the path specified in solrconfig.xml. This will ensure that the dataimport classes are loaded by the same classloader.

Please see the thread for more details.

OTHER TIPS

Paige Cook's answer is correct, but I'd like to add some details. I think you put the dataimporthandler jar into the common lib directory of your application server, while all solr jars are inside the WEB-INF/lib of solr.war. This means you're loading the dataimporthandler jar from a different classloader. You can solve it by putting your solr libraries in a different lib (external) directory. Then in your solr.xml you should refer to that lib folder through the sharedLib attribute. Something like this:

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false" sharedLib="lib">
    <cores adminPath="/admin/cores">
        <core name="core1" instanceDir="core1" />
    </cores>
</solr>

This way the Solr web application will load jars from that external location through its specific classloader.

As said by Paige Cook this is a class loader issue, you should add dataimport jars into a path used by Solr class loader. In order to define such lib path there are many options. Old versions of Solr (4.x and older) accepts an attribute sharedLib in the tag :

<solr persistent="false" sharedLib="lib"></solr>
  • sharedLib - Path to a directory containing .jar files that are added to the classpath of every core. The path is relative to solr.home (where solr.xml sits).

Newer versions of Solr (5.x and newer) use sharedLib as a child node of solr element.

<?xml version='1.0' encoding='UTF-8'?>
<solr>
  <str name='sharedLib'>lib</str>
</solr>

Even in this case the lib path is relative to solr.home (where solr.xml sits).

Another alternative is define a lib directive directly into the solrconfig.xml,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top