NPE creating EmbeddedSolrServer

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NPE creating EmbeddedSolrServer

Alexandre Rafalovitch
Hello,

I am trying to create a basic single-core embedded Solr instance. I
figured out how to setup a single core instance and got (I believe)
all files in right places. However,  I am unable to run trivial code
without exception:

        SolrServer solr = new EmbeddedSolrServer(
                new CoreContainer(
                    "D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm",
                    new
File("D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm\\solr.xml")),
                "core");

The exception (with context) is:

WARNING: No queryConverter defined, using default converter
Mar 17, 2009 6:15:01 PM org.apache.solr.core.QuerySenderListener newSearcher
INFO: QuerySenderListener sending requests to Searcher@b02928 main
Mar 17, 2009 6:15:01 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.NullPointerException
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:147)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1204)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1228)
        at org.apache.solr.core.QuerySenderListener.newSearcher(QuerySenderListener.java:50)
        at org.apache.solr.core.SolrCore$4.call(SolrCore.java:1034)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

Mar 17, 2009 6:15:02 PM org.apache.solr.core.SolrCore execute
INFO: [core] webapp=null path=null
params={start=0&q=fast_warm&rows=10} status=500 QTime=47

I am not sure where to look further. Source code (at my level of
knowledge) is not very helpful.

Regards,
   Alex.

Personal blog: http://blog.outerthoughts.com/
Research group: http://www.clt.mq.edu.au/Research/
Reply | Threaded
Open this post in threaded view
|

Re: NPE creating EmbeddedSolrServer

Alexandre Rafalovitch
To reply to my own message.

The following worked starting from scratch (example):
----------------------------------------------------------------------------------------------------

        SolrConfig solrConfig = new SolrConfig(
                "D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm\\solr",
                "solrconfig.xml",
                null);
        IndexSchema indexSchema = new IndexSchema(
                solrConfig,
                "schema.xml",
                null);

        CoreContainer container = new CoreContainer(new
SolrResourceLoader(SolrResourceLoader.locateInstanceDir()));
        CoreDescriptor dcore = new CoreDescriptor(container, "",
solrConfig.getResourceLoader().getInstanceDir());
        dcore.setConfigName(solrConfig.getResourceName());
        dcore.setSchemaName(indexSchema.getResourceName());
        SolrCore core = new SolrCore(
                null,

"D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm\\solr\\data",
                solrConfig, indexSchema, dcore);
        container.register("", core, false);
        SolrServer server = new EmbeddedSolrServer(container, "");

----------------------------------------------------------------------------------------------------

Not sure I get the magical sequence yet, but maybe it will save
somebody else half a day.

Regards,
   Alex.
Personal blog: http://blog.outerthoughts.com/
Research group: http://www.clt.mq.edu.au/Research/



On Tue, Mar 17, 2009 at 6:22 PM, Alexandre Rafalovitch
<[hidden email]> wrote:
> Hello,
>
> I am trying to create a basic single-core embedded Solr instance. I
> figured out how to setup a single core instance and got (I believe)
> all files in right places. However,  I am unable to run trivial code
> without exception:
Reply | Threaded
Open this post in threaded view
|

Re: NPE creating EmbeddedSolrServer

Clay Fink
This worked great. Thanks!

The only catch is you have to (eventually) call CoreContainer.shutdown(), otherwise the app just hangs.

Alexandre Rafalovitch wrote
To reply to my own message.

The following worked starting from scratch (example):
----------------------------------------------------------------------------------------------------

        SolrConfig solrConfig = new SolrConfig(
                "D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm\\solr",
                "solrconfig.xml",
                null);
        IndexSchema indexSchema = new IndexSchema(
                solrConfig,
                "schema.xml",
                null);

        CoreContainer container = new CoreContainer(new
SolrResourceLoader(SolrResourceLoader.locateInstanceDir()));
        CoreDescriptor dcore = new CoreDescriptor(container, "",
solrConfig.getResourceLoader().getInstanceDir());
        dcore.setConfigName(solrConfig.getResourceName());
        dcore.setSchemaName(indexSchema.getResourceName());
        SolrCore core = new SolrCore(
                null,

"D:\\Projects\\FutureTerm\\apache-solr-1.3.0\\futureterm\\solr\\data",
                solrConfig, indexSchema, dcore);
        container.register("", core, false);
        SolrServer server = new EmbeddedSolrServer(container, "");

----------------------------------------------------------------------------------------------------

Not sure I get the magical sequence yet, but maybe it will save
somebody else half a day.

Regards,
   Alex.
Personal blog: http://blog.outerthoughts.com/
Research group: http://www.clt.mq.edu.au/Research/



On Tue, Mar 17, 2009 at 6:22 PM, Alexandre Rafalovitch
<arafalov@gmail.com> wrote:
> Hello,
>
> I am trying to create a basic single-core embedded Solr instance. I
> figured out how to setup a single core instance and got (I believe)
> all files in right places. However,  I am unable to run trivial code
> without exception: