You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "David Smiley (JIRA)" <ji...@apache.org> on 2014/05/28 18:45:03 UTC

[jira] [Commented] (SOLR-4502) ShardHandlerFactory not initialized in CoreContainer when creating a Core manually.

    [ https://issues.apache.org/jira/browse/SOLR-4502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14011291#comment-14011291 ] 

David Smiley commented on SOLR-4502:
------------------------------------

This is annoying; it's bitten me twice now. I think if this is tackled, we should step back a bit and think about how to make it easier to create an EmbeddedSolrServer considering that an ESS is limited to a single SolrCore.  In light of that, the user shouldn't have to be bothered with a CoreContainer, and I argue not with a SolrConfig object either.  They should be able to point to a SolrCore's instance directory, _and that's it_.  Anything else is superfluous ceremony.

FYI I'm creating my CoreContainer like this, before I then do all the other stuff:
{code:java}
public static SolrServer createEmbeddedSolr(final String instanceDir) throws Exception {
    final String coreName = new File(instanceDir).getName();
    final String dataDir = instanceDir + "/../../cores_data/" + coreName;//or use null for default
    // note: this is more complex than it should be. See SOLR-4502
    SolrResourceLoader resourceLoader = new SolrResourceLoader(instanceDir);
    CoreContainer container = new CoreContainer(resourceLoader,
            ConfigSolr.fromString(resourceLoader, "<solr />") );
    container.load();
    CoreDescriptor descriptor = new CoreDescriptor(container, coreName, instanceDir);
    SolrConfig config = new SolrConfig(instanceDir, descriptor.getConfigName(), null);
    SolrCore core = new SolrCore(coreName, dataDir, config, null, descriptor);
    container.register(core, false);
    return new EmbeddedSolrServer(container, core.getName());
  }
{code}

> ShardHandlerFactory not initialized in CoreContainer when creating a Core manually.
> -----------------------------------------------------------------------------------
>
>                 Key: SOLR-4502
>                 URL: https://issues.apache.org/jira/browse/SOLR-4502
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 4.1
>            Reporter: Michael Aspetsberger
>            Assignee: Mark Miller
>              Labels: NPE
>             Fix For: 4.9, 5.0
>
>
> We are using an embedded solr server for our unit testing purposes. In our scenario, we create a {{CoreContainer}} using only the solr-home path, and then create the cores manually using a {{CoreDescriptor}}.
> While the creation appears to work fine, it hits an NPE when it handles the search:
> {quote}
> Caused by: java.lang.NullPointerException
> 	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:181)
> 	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
> 	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1816)
> 	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:150)
> {quote}
> According to http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201301.mbox/%3CE8A9BF60-5577-45F9-8BEA-B85616C6539D%40gmail.com%3E , this is due to a missing {{CoreContainer#load}}.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org