You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Phillip Rhodes <mo...@gmail.com> on 2012/01/06 01:45:50 UTC

"no such core" error with EmbeddedSolrServer

Hi all, I'm having an issue that I hope someone can shed some light on.

I have a Groovy program, using Solr 3.5, where I am attempting to use
EmbeddedSolrServer using the instructions shown here:

http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer

to that end, I have code setup like this:

...

System.setProperty('solr.solr.home',
'/usr/servers/solr/apache-solr-3.5.0/example/heceta');
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();

EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, '' );

to initialize the solrServer.  But when I try to add a doc using the solrServer
instance, I get an exception:

org.apache.solr.common.SolrException: No such core:
	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:104)
	at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121)
	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:106)
	at org.apache.solr.client.solrj.SolrServer$add.call(Unknown Source)
	at org.fogbeam.exp.IndexerWithOwnerInfo.indexFile(IndexerWithOwnerInfo.groovy:150)


My solr.xml looks like this:

<solr persistent="false">

  <!--
  adminPath: RequestHandler path to manage cores.
    If 'null' (or absent), cores will not be manageable via request handler
  -->
  <cores adminPath="/admin/cores" defaultCoreName="collection1">
    <core name="collection1" instanceDir="." />
  </cores>
</solr>



Can somebody tell me if the documentation on how to set this up is
wrong, or if there is a solr bug, or if there
is just something I've missed in my configuration?


Thanks,


Phillip

[SOLVED] [MORE OR LESS] "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
OK, this is working now.  There were a couple of things going on, but
the net-net was "classloading issues."
The initial "no such core" problem was happening because the cores
weren't initializing properly due
to a NoClassDefFoundError.   But after fixing that, I wound up with a
pile of ClassCastExceptions... the kind
you get when there are Classloader conflicts...  I'd seen this kind of
thing before when using Groovy (possibly
because it does extra classloading trickery under the covers?) so I
ported the program to plain old Java
and it works fine.

No biggie... at this point, I've basiclaly decided I'm going to run
Solr as a separate process anyway, and use
the http based SolrJ client for integration, and that works fine even
in the Groovy code.


Thanks for all the help, tips and pointers!  I've learned a lot about
Solr in the past day or two.  :-)



Phil

On Thu, Jan 5, 2012 at 7:45 PM, Phillip Rhodes
<mo...@gmail.com> wrote:
> Hi all, I'm having an issue that I hope someone can shed some light on.
>
> I have a Groovy program, using Solr 3.5, where I am attempting to use
> EmbeddedSolrServer using the instructions shown here:
>
> http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer
>
> to that end, I have code setup like this:
>
> ...
>
> System.setProperty('solr.solr.home',
> '/usr/servers/solr/apache-solr-3.5.0/example/heceta');
> CoreContainer.Initializer initializer = new CoreContainer.Initializer();
> CoreContainer coreContainer = initializer.initialize();
>
> EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, '' );
>
> to initialize the solrServer.  But when I try to add a doc using the solrServer
> instance, I get an exception:
>
> org.apache.solr.common.SolrException: No such core:
>        at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:104)
>        at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
>        at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121)
>        at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:106)
>        at org.apache.solr.client.solrj.SolrServer$add.call(Unknown Source)
>        at org.fogbeam.exp.IndexerWithOwnerInfo.indexFile(IndexerWithOwnerInfo.groovy:150)
>
>
> My solr.xml looks like this:
>
> <solr persistent="false">
>
>  <!--
>  adminPath: RequestHandler path to manage cores.
>    If 'null' (or absent), cores will not be manageable via request handler
>  -->
>  <cores adminPath="/admin/cores" defaultCoreName="collection1">
>    <core name="collection1" instanceDir="." />
>  </cores>
> </solr>
>
>
>
> Can somebody tell me if the documentation on how to set this up is
> wrong, or if there is a solr bug, or if there
> is just something I've missed in my configuration?
>
>
> Thanks,
>
>
> Phillip

Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
2012/1/6 Yury Kats <yu...@yahoo.com>:
>
> That probably means the home is not set properly, so it can't find solr.xml
>
Well, all the docs mention doing is this bit, which I have:

System.setProperty('solr.solr.home',
'/usr/servers/solr/apache-solr-3.5.0/example/heceta');

I've also tried it the other way mentioned on the wiki, where you do this:

File home = new File( "/path/to/solr/home" );
    File f = new File( home, "solr.xml" );
    CoreContainer container = new CoreContainer();
    container.load( "/path/to/solr/home", f );

    EmbeddedSolrServer server = new EmbeddedSolrServer( container,
"core name as defined in solr.xml" );

and I get the exact same error when trying that approach as well.  :-(


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
On Fri, Jan 6, 2012 at 11:28 AM, Christopher Childs <cj...@me.com> wrote:
> Multicore does work with EmbeddedSolrServer. It's what we use in our application.
>
> solr.xml is also relevant for configuring the cores. We do not do it in quite the same manner that Phillip is describing, though. Our CoreContainer is initialized by SolrDispatchFilter. After the core container is created, we just do 'new EmbeddedSolrServer(cores, "firstCoreNameInSolrXml");' -- it even worked without a core name specified, but the behavior was erratic and incorrect in other ways in that case.

Cool, that's good to know.

>
> I would suggest enabling logging for the Solr classes that are likely to help explain some of the mystery here: SolrResourceLoader, and CoreContainer. At the info level, they will tell you where they are finding solr.xml and how they are finding it (whether it's passed in via constructor arguments, or through solr.solr.home).


I'll look into that this afternoon then.   Thanks for the pointer.


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Christopher Childs <cj...@me.com>.
Multicore does work with EmbeddedSolrServer. It's what we use in our application.

solr.xml is also relevant for configuring the cores. We do not do it in quite the same manner that Phillip is describing, though. Our CoreContainer is initialized by SolrDispatchFilter. After the core container is created, we just do 'new EmbeddedSolrServer(cores, "firstCoreNameInSolrXml");' -- it even worked without a core name specified, but the behavior was erratic and incorrect in other ways in that case.

I would suggest enabling logging for the Solr classes that are likely to help explain some of the mystery here: SolrResourceLoader, and CoreContainer. At the info level, they will tell you where they are finding solr.xml and how they are finding it (whether it's passed in via constructor arguments, or through solr.solr.home).

On Jan 6, 2012, at 11:03 AM, Erik Hatcher wrote:

> 
> On Jan 6, 2012, at 10:46 , Yury Kats wrote:
> 
>> On 1/6/2012 10:19 AM, Phillip Rhodes wrote:
>>> 2012/1/6 Yury Kats <yu...@yahoo.com>:
>>>> 
>>>> Have you tried passing core name (collection1) to the c'tor, instead
>>>> of the empty string?
>>> 
>>> Yep, but that gives the same error (with the core name appended) such
>>> as "no such core: collection1"
>> 
>> That probably means the home is not set properly, so it can't find solr.xml
>> 
> 
> Again, EmbeddedSolrServer (unless I'm gravely mistaken!) doesn't do multicore.  It's for a single core.  If you want multiple cores supported... created multiple EmbeddedSolrServer instances.   You point the instance to the core's "home".
> 
> 	Erik
> 

-- 
Christopher Childs




Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
On Fri, Jan 6, 2012 at 11:03 AM, Erik Hatcher <er...@gmail.com> wrote:
>
> Again, EmbeddedSolrServer (unless I'm gravely mistaken!) doesn't do multicore.  It's for a single core.  If you want multiple cores
> supported... created multiple EmbeddedSolrServer instances.   You point the instance to the core's "home".

At this very moment, all I personally care about is getting it to work
with one core.  However, even when I take the approach shown in the
documentation, under where it says "if you want to user multicore
features" it still errors out the same way.  That is,

File home = new File( "/path/to/solr/home" );
    File f = new File( home, "solr.xml" );
    CoreContainer container = new CoreContainer();
    container.load( "/path/to/solr/home", f );

    EmbeddedSolrServer server = new EmbeddedSolrServer( container,
"core name as defined in solr.xml" );

It's still showing the configuration as driving off of solr.xml,
although it does tell you to pass the core name explicitly to the
ctor.  But if you're saying that solr.xml isn't used when using
EmbeddedSolrServer, is this example even relevant at all?

When I get home from the $dayjob later and can revisit this, I'll try
the first approach, with the path pointing all the way down to the
specific core.  If that works, I'll be happy, but I'm thinking this
wiki page may need some updating by somebody who understands how all
this works...  :-)


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Erik Hatcher <er...@gmail.com>.
On Jan 6, 2012, at 10:46 , Yury Kats wrote:

> On 1/6/2012 10:19 AM, Phillip Rhodes wrote:
>> 2012/1/6 Yury Kats <yu...@yahoo.com>:
>>> 
>>> Have you tried passing core name (collection1) to the c'tor, instead
>>> of the empty string?
>> 
>> Yep, but that gives the same error (with the core name appended) such
>> as "no such core: collection1"
> 
> That probably means the home is not set properly, so it can't find solr.xml
> 

Again, EmbeddedSolrServer (unless I'm gravely mistaken!) doesn't do multicore.  It's for a single core.  If you want multiple cores supported... created multiple EmbeddedSolrServer instances.   You point the instance to the core's "home".

	Erik


Re: "no such core" error with EmbeddedSolrServer

Posted by Yury Kats <yu...@yahoo.com>.
On 1/6/2012 10:19 AM, Phillip Rhodes wrote:
> 2012/1/6 Yury Kats <yu...@yahoo.com>:
>>
>> Have you tried passing core name (collection1) to the c'tor, instead
>> of the empty string?
> 
> Yep, but that gives the same error (with the core name appended) such
> as "no such core: collection1"

That probably means the home is not set properly, so it can't find solr.xml


Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
2012/1/6 Yury Kats <yu...@yahoo.com>:
>
> Have you tried passing core name (collection1) to the c'tor, instead
> of the empty string?

Yep, but that gives the same error (with the core name appended) such
as "no such core: collection1"


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Yury Kats <yu...@yahoo.com>.
On 1/6/2012 9:57 AM, Phillip Rhodes wrote:
> On Fri, Jan 6, 2012 at 3:06 AM, Sven Maurmann <sv...@kippdata.de> wrote:
>> Hi,
>>
>> from your snippets the reason is not completely clear. There are a number of reasons for not starting up the
>> server. For example in case of a faulty configuration of the core (solrconfig.xml, schema.xml) the core does
>> not start and you get the reported error.
> 
> Yeah, that I noticed... I had some such errors earlier, that I noticed
> when starting the Solr / Jetty standalone instance, but those have
> been resolved, and now I can launch Solr as a process, and use the
> SolrJ implementation that talks http to it - from my program - and
> everything works as expected.  But still no joy with the
> EmbeddedSolrServer.  :-(

Have you tried passing core name (collection1) to the c'tor, instead
of the empty string?

Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
On Fri, Jan 6, 2012 at 3:06 AM, Sven Maurmann <sv...@kippdata.de> wrote:
> Hi,
>
> from your snippets the reason is not completely clear. There are a number of reasons for not starting up the
> server. For example in case of a faulty configuration of the core (solrconfig.xml, schema.xml) the core does
> not start and you get the reported error.

Yeah, that I noticed... I had some such errors earlier, that I noticed
when starting the Solr / Jetty standalone instance, but those have
been resolved, and now I can launch Solr as a process, and use the
SolrJ implementation that talks http to it - from my program - and
everything works as expected.  But still no joy with the
EmbeddedSolrServer.  :-(

If nothing obvious jumps out at anybody, I guess I'll just put a
breakpoint in the code that initializes the EmbeddedSolrServer and
start stepping through it and see if I can sort out what's going on...


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Phillip Rhodes <mo...@gmail.com>.
On Fri, Jan 6, 2012 at 8:06 AM, Erik Hatcher <er...@gmail.com> wrote:
> Also note that an EmbeddedSolrServer is for a specific core, not for all cores (and thus solr.xml is not used).  My hunch is that you > need to point to the core's home directory, not to the parent of solr.xml.

Oh, interesting.  The example on the Solr wiki had given me the
impression that it's the other way, but I'll definitely give that a
try.  Thanks for the heads-up.


Phil

Re: "no such core" error with EmbeddedSolrServer

Posted by Erik Hatcher <er...@gmail.com>.
Also note that an EmbeddedSolrServer is for a specific core, not for all cores (and thus solr.xml is not used).  My hunch is that you need to point to the core's home directory, not to the parent of solr.xml.

	Erik



On Jan 6, 2012, at 03:06 , Sven Maurmann wrote:

> Hi,
> 
> from your snippets the reason is not completely clear. There are a number of reasons for not starting up the
> server. For example in case of a faulty configuration of the core (solrconfig.xml, schema.xml) the core does
> not start and you get the reported error.
> 
> Best,
>   Sven
> 
> Am 06.01.2012 um 01:45 schrieb Phillip Rhodes:
> 
>> Hi all, I'm having an issue that I hope someone can shed some light on.
>> 
>> I have a Groovy program, using Solr 3.5, where I am attempting to use
>> EmbeddedSolrServer using the instructions shown here:
>> 
>> http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer
>> 
>> to that end, I have code setup like this:
>> 
>> ...
>> 
>> System.setProperty('solr.solr.home',
>> '/usr/servers/solr/apache-solr-3.5.0/example/heceta');
>> CoreContainer.Initializer initializer = new CoreContainer.Initializer();
>> CoreContainer coreContainer = initializer.initialize();
>> 
>> EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, '' );
>> 
>> to initialize the solrServer.  But when I try to add a doc using the solrServer
>> instance, I get an exception:
>> 
>> org.apache.solr.common.SolrException: No such core:
>> 	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:104)
>> 	at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
>> 	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121)
>> 	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:106)
>> 	at org.apache.solr.client.solrj.SolrServer$add.call(Unknown Source)
>> 	at org.fogbeam.exp.IndexerWithOwnerInfo.indexFile(IndexerWithOwnerInfo.groovy:150)
>> 
>> 
>> My solr.xml looks like this:
>> 
>> <solr persistent="false">
>> 
>> <!--
>> adminPath: RequestHandler path to manage cores.
>>   If 'null' (or absent), cores will not be manageable via request handler
>> -->
>> <cores adminPath="/admin/cores" defaultCoreName="collection1">
>>   <core name="collection1" instanceDir="." />
>> </cores>
>> </solr>
>> 
>> 
>> 
>> Can somebody tell me if the documentation on how to set this up is
>> wrong, or if there is a solr bug, or if there
>> is just something I've missed in my configuration?
>> 
>> 
>> Thanks,
>> 
>> 
>> Phillip
> 


Re: "no such core" error with EmbeddedSolrServer

Posted by Sven Maurmann <sv...@kippdata.de>.
Hi,

from your snippets the reason is not completely clear. There are a number of reasons for not starting up the
server. For example in case of a faulty configuration of the core (solrconfig.xml, schema.xml) the core does
not start and you get the reported error.

Best,
   Sven

Am 06.01.2012 um 01:45 schrieb Phillip Rhodes:

> Hi all, I'm having an issue that I hope someone can shed some light on.
> 
> I have a Groovy program, using Solr 3.5, where I am attempting to use
> EmbeddedSolrServer using the instructions shown here:
> 
> http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer
> 
> to that end, I have code setup like this:
> 
> ...
> 
> System.setProperty('solr.solr.home',
> '/usr/servers/solr/apache-solr-3.5.0/example/heceta');
> CoreContainer.Initializer initializer = new CoreContainer.Initializer();
> CoreContainer coreContainer = initializer.initialize();
> 
> EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, '' );
> 
> to initialize the solrServer.  But when I try to add a doc using the solrServer
> instance, I get an exception:
> 
> org.apache.solr.common.SolrException: No such core:
> 	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:104)
> 	at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
> 	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121)
> 	at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:106)
> 	at org.apache.solr.client.solrj.SolrServer$add.call(Unknown Source)
> 	at org.fogbeam.exp.IndexerWithOwnerInfo.indexFile(IndexerWithOwnerInfo.groovy:150)
> 
> 
> My solr.xml looks like this:
> 
> <solr persistent="false">
> 
>  <!--
>  adminPath: RequestHandler path to manage cores.
>    If 'null' (or absent), cores will not be manageable via request handler
>  -->
>  <cores adminPath="/admin/cores" defaultCoreName="collection1">
>    <core name="collection1" instanceDir="." />
>  </cores>
> </solr>
> 
> 
> 
> Can somebody tell me if the documentation on how to set this up is
> wrong, or if there is a solr bug, or if there
> is just something I've missed in my configuration?
> 
> 
> Thanks,
> 
> 
> Phillip