Reputation: 639
I want to update my solr based application from Solr 4 to Solr 5.3.1
I just found out, since Solr 5.2 it is no longer possible to run Solr as a WebApp. So instead of packaging the project (with solr as Maven dependencies) as a WAR and running it with a separate Jetty, now I need to put my source code into the Solr. But how can i do this?
I tried to package my project as a JAR and put it in the folder /solr-5.3.1/contrib/mySearchApplication/lib/mysearch.jar
and I added this path in solrconfig.xml <lib dir="${solr.install.dir:../../../..}/contrib/mySearchApplication/lib" regex=".*\.jar" />
but when I try to run Solr it still can't find my Classes, e.g. my customized token filters.
So how can I add my java classes to solr?
I get this error message:
ERROR (coreLoadExecutor-6-thread-1) [ ] o.a.s.c.CoreContainer Error creating core [myCollection]: Could not load conf for core myCollection: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml
org.apache.solr.common.SolrException: Could not load conf for core myCollection: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml
at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:80)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:721)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:443)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:434)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:210)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:596)
at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:175)
at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
at org.apache.solr.core.ConfigSetService.createIndexSchema(ConfigSetService.java:104)
at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:75)
... 8 more
Upvotes: 0
Views: 2114
Reputation: 1064
In Windows solr.xml may look like this:
<solr>
<str name='sharedLib'>F:\solr_deployment\solr-7.6.0\contrib\analysis-extras\lucene-libs</str>
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<str name="hostContext">${hostContext:solr}</str>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
<int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
<str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
<str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:600000}</int>
<int name="connTimeout">${connTimeout:60000}</int>
</shardHandlerFactory>
</solr>
Alternatively, one may have this in solrconfig.xml file:
<config>
<luceneMatchVersion>7.6.0</luceneMatchVersion>
<lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/velocity/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-velocity-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-analysis-\d.*\.jar" />
...
</config>
Upvotes: 0
Reputation: 30167
You can add the sharedLib
parameter into the solr.xml file.
This parameter specifies the path to a common library directory that will be shared across all cores. Any JAR files in this directory will be added to the search path for Solr plugins. This path is relative to the top-level container's Solr Home.
Here is how I did.
<?xml version='1.0' encoding='UTF-8'?>
<solr>
<str name='sharedLib'>/opt/shared-lib</str>
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${hostPort:8080}</int>
<str name="hostContext">${hostContext:solr}</str>
<int name="zkClientTimeout">${zkClientTimeout:15000}</int>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:0}</int>
<int name="connTimeout">${connTimeout:0}</int>
</shardHandlerFactory>
</solr>
Upvotes: 1