3
votes

I am trying to use the support that was added for specifying jars as runtime libraries when creating request handler's and other components. However, it is not clear to me from the documentation (https://cwiki.apache.org/confluence/display/solr/Adding+Custom+Plugins+in+SolrCloud+Mode) whether this only works through components created through the ConfigAPI or if it should also work if runtimeLib="true" is added to solrconfig.xml.

For example:

<requestHandler name="/browse" class="solr.SearchHandler" runtimeLib="true">

I added runtimeLib="true" to all of my searchComponents and requestHandlers in solrconfig.xml to see if it would work, but when starting the Solr instances, they all fail because they are looking for a class that is in a custom jar file. I've added the .system collection and uploaded the jars per the Solr Reference Guide/Wiki documentation and can see the .system collection and I can also see that my collection's configoverlay.json has the two jars I uploaded.

My collection's configoverlay.json contents

{"runtimeLib":{
    "my-custom-jar":{
      "name":"my-custom-jar",
      "version":1},
    "sqljdbc41-jar":{
      "name":"sqljdbc41-jar",
      "version":1}}}

Is specifying a runtimeLib attribute in solrconfig.xml supported? If so, what is the proper usage?

2

2 Answers

0
votes

You're almost there. Further down on the page that you are linking to there is an example of creating a parser. The example uses completely different example values than the rest of the page, so I can understand why you may have glossed over it.

The point is, that you need to register your request handler using the curl command provided on the page. Unfortunately, you need to use a command that I had to dig into the source code to find: create-requesthandler. To create a request handler using your values above, I think you should issue the command

curl "http://{servername}:8983/solr/{collection}/config" -H 'Content-type:application/json' -d '{
    "create-requesthandler": { 
        "name":"my-custom-jar", 
        "runtimeLib": true, 
        "class": "solr.SearchHandler" 
    }
}'

remember to replace the values of servername and collection. And change the port if you are using a non-default value.

Restart your solr server and the plugin should be available.

0
votes

Sadly loading classes from plugins in managed schemas seems to be unsupported at the moment:

https://issues.apache.org/jira/browse/SOLR-8751

This probably means that you have to add it dynamically via the API as mentioned above. So the solution could be to use a minimal managed schema and add the fields requiring external jars afterwards.

For me, the simplest solution was not to use the Blob API at all, and directly add the required jars to the classpath of the Solr instance, as described here:

http://lucene.472066.n3.nabble.com/Problems-while-setting-classpath-while-upgrading-to-Solr-5-1-from-Solr-4-X-tp4209853p4209863.html