Why can't I instantiate DataImportHandler in Solr on JBoss?

前端 未结 3 1587
Happy的楠姐
Happy的楠姐 2020-12-11 20:59

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

相关标签:
3条回答
  • 2020-12-11 21:11

    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,

    0 讨论(0)
  • 2020-12-11 21:24

    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.

    0 讨论(0)
  • 2020-12-11 21:27

    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.

    0 讨论(0)
提交回复
热议问题