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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With