Re: EmbeddedSolrServer problem when using one-jar-with-dependency including solr

2016-08-03 Thread Steve Rowe
Oh, then likely the problem is that your uberjar packing tool doesn’t know how 
to (or maybe isn’t configured to?) include/merge/translate resources under 
META-INF/services/.  E.g. lucene/core module has SPI files there.

Info on the maven shade plugin’s configuration for this stuff is here here: 


--
Steve
www.lucidworks.com

> On Aug 3, 2016, at 5:26 AM, Ziqi Zhang  wrote:
> 
> Thanks
> 
> I am not sure if Steve's suggestion was the right solution. Even when I did 
> not have explicitly defined the dependency on lucene, I can see in the 
> packaged jar it still contains org.apache.lucene.
> 
> What solved my problem is to not pack a single jar but use a folder of 
> individual jars. I am not sure why though.
> 
> Regards
> 
> 
> On 02/08/2016 21:53, Rohit Kanchan wrote:
>> We also faced same issue when we were running embedded solr 6.1 server.
>> Actually I faced the same in our integration environment after deploying
>> project. Solr 6.1 is using http client 4.4.1 which I think  embedded solr
>> server is looking for. I think when solr core is getting loaded then old
>> http client is getting loaded from some where in your maven. Check
>> dependency tree of your pom.xml and see if you can exclude this jar getting
>> loaded from anywhere else. Just exclude them in your pom.xml. I hope this
>> solves your issue,
>> 
>> 
>> Thanks
>> Rohit
>> 
>> 
>> On Tue, Aug 2, 2016 at 9:44 AM, Steve Rowe  wrote:
>> 
>>> 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
>>>  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] 
>>> [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 
>>> 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 /*
 
org.apache.jena
jena-arq
3.0.1

 

 BLOCK A
 org.apache.httpcomponents
httpclient
4.5.2
 BLOCK A ENDS


org.apache.solr
solr-core
6.1.0


org.slf4j
 slf4j-log4j12


log4j
log4j



Re: EmbeddedSolrServer problem when using one-jar-with-dependency including solr

2016-08-03 Thread Ziqi Zhang

Thanks

I am not sure if Steve's suggestion was the right solution. Even when I 
did not have explicitly defined the dependency on lucene, I can see in 
the packaged jar it still contains org.apache.lucene.


What solved my problem is to not pack a single jar but use a folder of 
individual jars. I am not sure why though.


Regards


On 02/08/2016 21:53, Rohit Kanchan wrote:

We also faced same issue when we were running embedded solr 6.1 server.
Actually I faced the same in our integration environment after deploying
project. Solr 6.1 is using http client 4.4.1 which I think  embedded solr
server is looking for. I think when solr core is getting loaded then old
http client is getting loaded from some where in your maven. Check
dependency tree of your pom.xml and see if you can exclude this jar getting
loaded from anywhere else. Just exclude them in your pom.xml. I hope this
solves your issue,


Thanks
Rohit


On Tue, Aug 2, 2016 at 9:44 AM, Steve Rowe  wrote:


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
 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] 
[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 

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 /*

org.apache.jena
jena-arq
3.0.1




 BLOCK A
org.apache.httpcomponents
httpclient
4.5.2
 BLOCK A ENDS



org.apache.solr
solr-core
6.1.0


org.slf4j
slf4j-log4j12


log4j
log4j


org.slf4j
slf4j-jdk14




org.apache.solr
solr-solrj
6.1.0


org.slf4j
slf4j-log4j12


log4j
log4j


org.slf4j
slf4j-jdk14



///


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


Re: EmbeddedSolrServer problem when using one-jar-with-dependency including solr

2016-08-02 Thread Rohit Kanchan
We also faced same issue when we were running embedded solr 6.1 server.
Actually I faced the same in our integration environment after deploying
project. Solr 6.1 is using http client 4.4.1 which I think  embedded solr
server is looking for. I think when solr core is getting loaded then old
http client is getting loaded from some where in your maven. Check
dependency tree of your pom.xml and see if you can exclude this jar getting
loaded from anywhere else. Just exclude them in your pom.xml. I hope this
solves your issue,


Thanks
Rohit


On Tue, Aug 2, 2016 at 9:44 AM, Steve Rowe  wrote:

> 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
>  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] 
> [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 
> 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 /*
> > 
> >org.apache.jena
> >jena-arq
> >3.0.1
> >
> >
> >
> > BLOCK A
> > org.apache.httpcomponents
> >httpclient
> >4.5.2
> > BLOCK A ENDS
> >
> >
> >org.apache.solr
> >solr-core
> >6.1.0
> >
> >
> >org.slf4j
> > slf4j-log4j12
> >
> >
> >log4j
> >log4j
> >
> >
> >org.slf4j
> > slf4j-jdk14
> >
> >
> >
> >
> >org.apache.solr
> >solr-solrj
> >6.1.0
> >
> >
> >org.slf4j
> > slf4j-log4j12
> >
> >
> >log4j
> >log4j
> >
> >
> >org.slf4j
> > slf4j-jdk14
> >
> >
> >
> > ///
> >
> >
> > 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)
> >   

Re: EmbeddedSolrServer problem when using one-jar-with-dependency including solr

2016-08-02 Thread Steve Rowe
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 
 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] 

[2] 

[3] 

[4] 

[5] 
[6] 


--
Steve
www.lucidworks.com

> On Aug 2, 2016, at 12:03 PM, Ziqi Zhang  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 /*
> 
>org.apache.jena
>jena-arq
>3.0.1
>
> 
>
> BLOCK A
> org.apache.httpcomponents
>httpclient
>4.5.2
> BLOCK A ENDS
>
>
>org.apache.solr
>solr-core
>6.1.0
>
>
>org.slf4j
> slf4j-log4j12
>
>
>log4j
>log4j
>
>
>org.slf4j
> slf4j-jdk14
>
>
>
>
>org.apache.solr
>solr-solrj
>6.1.0
>
>
>org.slf4j
> slf4j-log4j12
>
>
>log4j
>log4j
>
>
>org.slf4j
> slf4j-jdk14
>
>
>
> ///
> 
> 
> 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.(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.(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 
> 

EmbeddedSolrServer problem when using one-jar-with-dependency including solr

2016-08-02 Thread Ziqi Zhang
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 /*

org.apache.jena
jena-arq
3.0.1




 BLOCK A
org.apache.httpcomponents
httpclient
4.5.2
 BLOCK A ENDS



org.apache.solr
solr-core
6.1.0


org.slf4j
slf4j-log4j12


log4j
log4j


org.slf4j
slf4j-jdk14




org.apache.solr
solr-solrj
6.1.0


org.slf4j
slf4j-log4j12


log4j
log4j


org.slf4j
slf4j-jdk14



///


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.(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.(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.(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.(SolrCore.java:773)
at