lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Rowe <sar...@gmail.com>
Subject Re: EmbeddedSolrServer problem when using one-jar-with-dependency including solr
Date Tue, 02 Aug 2016 16:44:25 GMT
solr-core[1] and solr-solrj[2] POMs have parent POM solr-parent[3], which in turn has parent
POM lucene-solr-grandparent[4], which has a <dependencyManagement> section that specifies
dependency versions & exclusions *for all direct dependencies*.

The intent is for all Lucene/Solr’s internal dependencies to be managed directly, rather
than through Maven’s transitive dependency mechanism.  For background, see summary &
comments on JIRA issue LUCENE-5217[5].

I haven’t looked into how this affects systems that depend on Lucene/Solr artifacts, but
it appears to be the case that you can’t use Maven’s transitive dependency mechanism to
pull in all required dependencies for you.

BTW, if you look at the grandparent POM, the httpclient version for Solr 6.1.0 is declared
as 4.4.1.  I don’t know if depending on version 4.5.2 is causing problems, but if you don’t
need a feature in 4.5.2, I suggest that you depend on the same version as Solr does.

For error #2, you should depend on lucene-core[6].

My suggestion as a place to start: copy/paste the dependencies from solr-core[1] and solr-solrj[2]
POMs, and leave out stuff you know you won’t need.

[1] <https://repo1.maven.org/maven2/org/apache/solr/solr-core/6.1.0/solr-core-6.1.0.pom>
[2] <https://repo1.maven.org/maven2/org/apache/solr/solr-solrj/6.1.0/solr-solrj-6.1.0.pom>
[3] <https://repo1.maven.org/maven2/org/apache/solr/solr-parent/6.1.0/solr-parent-6.1.0.pom>
[4] <https://repo1.maven.org/maven2/org/apache/lucene/lucene-solr-grandparent/6.1.0/lucene-solr-grandparent-6.1.0.pom>
[5] <https://issues.apache.org/jira/browse/LUCENE-5217>
[6] <http://search.maven.org/#artifactdetails|org.apache.lucene|lucene-core|6.1.0|jar>

--
Steve
www.lucidworks.com

> On Aug 2, 2016, at 12:03 PM, Ziqi Zhang <ziqi.zhang@sheffield.ac.uk> wrote:
> 
> Hi, I am using Solr, Solrj 6.1, and Maven to manage my project. I use maven to build
a jar-with-dependency and run a java program pointing its classpath to this jar. However I
keep getting errors even when I just try to create an instance of EmbeddedSolrServer:
> 
> */////////code/////////
> *String solrHome = "/home/solr/";
> String solrCore = "fw";
> solrCores = new EmbeddedSolrServer(
>                    Paths.get(solrHome), solrCore
>            ).getCoreContainer();
> ///////////////////////
> 
> 
> My project has dependencies defined in the pom shown below:  **When block A is not present**,
running the code that calls:
> 
> *//////// pom /////////*
> <dependency>
>                <groupId>org.apache.jena</groupId>
>                <artifactId>jena-arq</artifactId>
>                <version>3.0.1</version>
>            </dependency>
> 
>            <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
-->
>            <dependency> ////////////////////BLOCK A
> <groupId>org.apache.httpcomponents</groupId>
>                <artifactId>httpclient</artifactId>
>                <version>4.5.2</version>
>            </dependency> ////////////////////BLOCK A ENDS
>            <!-- https://mvnrepository.com/artifact/org.apache.solr/solr-solrj -->
>            <dependency>
>                <groupId>org.apache.solr</groupId>
>                <artifactId>solr-core</artifactId>
>                <version>6.1.0</version>
>                <exclusions>
>                    <exclusion>
>                        <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
>                    </exclusion>
>                    <exclusion>
>                        <groupId>log4j</groupId>
>                        <artifactId>log4j</artifactId>
>                    </exclusion>
>                    <exclusion>
>                        <groupId>org.slf4j</groupId>
> <artifactId>slf4j-jdk14</artifactId>
>                    </exclusion>
>                </exclusions>
>            </dependency>
>            <dependency>
>                <groupId>org.apache.solr</groupId>
>                <artifactId>solr-solrj</artifactId>
>                <version>6.1.0</version>
>                <exclusions>
>                    <exclusion>
>                        <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
>                    </exclusion>
>                    <exclusion>
>                        <groupId>log4j</groupId>
>                        <artifactId>log4j</artifactId>
>                    </exclusion>
>                    <exclusion>
>                        <groupId>org.slf4j</groupId>
> <artifactId>slf4j-jdk14</artifactId>
>                    </exclusion>
>                </exclusions>
>            </dependency>
> ///////////////////
> 
> 
> Block A is added because when it is missing, the following error is thrown on the java
code above:
> 
> *//////// ERROR 1 ///////////*
> 
>    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/CloseableHttpClient
>        at org.apache.solr.handler.component.HttpShardHandlerFactory.init(HttpShardHandlerFactory.java:167)
>        at org.apache.solr.handler.component.ShardHandlerFactory.newInstance(ShardHandlerFactory.java:47)
>        at org.apache.solr.core.CoreContainer.load(CoreContainer.java:404)
>        at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.load(EmbeddedSolrServer.java:84)
>        at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.<init>(EmbeddedSolrServer.java:70)
>        at uk.ac.ntu.sac.sense.SenseProperty.initSolrServer(SenseProperty.java:103)
>        at uk.ac.ntu.sac.sense.SenseProperty.getClassIndex(SenseProperty.java:81)
>        at uk.ac.ntu.sac.sense.kb.indexer.IndexMaster.<init>(IndexMaster.java:31)
>        at uk.ac.ntu.sac.sense.test.TestIndexer.main(TestIndexer.java:14)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>        at java.lang.reflect.Method.invoke(Method.java:497)
>        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
>    Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.client.CloseableHttpClient
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>        ... 14 more
> ////////////////////
> 
> 
> So I looked up online add Block A into pom, run maven clean install to build a jar-with-dependencies,
and then start the program point to that jar as classpath, I get this error on the java code
shown above:
> 
> *////////// ERROR 2//////////*
>    xception in thread "main" org.apache.solr.common.SolrException: SolrCore 'class' is
not available due to init failure: An SPI class of type org.apache.lucene.codecs.PostingsFormat
with name 'Lucene50' does not exist.  You need to add the corresponding JAR file supporting
this SPI to your classpath.  The current classpath supports the following names: []
>        at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1066)
>        at uk.ac.ntu.sac.sense.SenseProperty.getClassIndex(SenseProperty.java:84)
>        at uk.ac.ntu.sac.sense.kb.indexer.IndexMaster.<init>(IndexMaster.java:31)
>        at uk.ac.ntu.sac.sense.test.TestIndexer.main(TestIndexer.java:14)
>    Caused by: org.apache.solr.common.SolrException: An SPI class of type org.apache.lucene.codecs.PostingsFormat
with name 'Lucene50' does not exist.  You need to add the corresponding JAR file supporting
this SPI to your classpath.  The current classpath supports the following names: []
>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:773)
>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:647)
>        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:812)
>        at org.apache.solr.core.CoreContainer.lambda$load$0(CoreContainer.java:466)
>        at org.apache.solr.core.CoreContainer$$Lambda$2/388043093.call(Unknown Source)
>        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>        at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$22(ExecutorUtil.java:229)
>        at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$$Lambda$3/369241501.run(Unknown
Source)
>        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>        at java.lang.Thread.run(Thread.java:745)
>    Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat
with name 'Lucene50' does not exist.  You need to add the corresponding JAR file supporting
this SPI to your classpath.  The current classpath supports the following names: []
>        at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:116)
>        at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
>        at org.apache.lucene.codecs.lucene60.Lucene60Codec.<init>(Lucene60Codec.java:167)
>        at org.apache.solr.core.SchemaCodecFactory$1.<init>(SchemaCodecFactory.java:94)
>        at org.apache.solr.core.SchemaCodecFactory.init(SchemaCodecFactory.java:94)
>        at org.apache.solr.core.SolrCore.initCodec(SolrCore.java:981)
>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:717)
>        ... 10 more
> 
> 
> 
> Any suggestions highly appreciated


Mime
View raw message