This is my fault - I discovered this myself a few days ago. I've been meaning 
to file a jira ticket and have not gotten around to it yet.

You can also work around it like this:

    CoreContainer container = new CoreContainer(loader) {
      // workaround since we don't call container#load
      {initShardHandler(null);}
    };

- Mark

On Jan 24, 2013, at 9:22 AM, Ted Merchant <ted.merch...@cision.com> wrote:

> We recently updated from Solr 4.0.0 to Solr 4.1.0.  Because of the change we 
> were forced to upgrade a custom query parser.  While the code change itself 
> was minimal, we found that our unit tests stopped working because of a 
> NullPointerException on line 181 of handler.component.SearchHandler:
> ShardHandler shardHandler1 = shardHandlerFactory.getShardHandler();
> We determined that the cause of this exception was that shardHandlerFactory 
> was never initialized in the solr container.  The reason for this seems to be 
> that the shard handler is setup in core.CoreContainer::initShardHandler which 
> is called from core.CoreContainer::load. 
> When setting up the core container we were using the  public 
> CoreContainer(SolrResourceLoader loader) constructor.  This constructor never 
> calls the load method, so initShardHandler is never called and the 
> shardHandler is never initialized. 
> In Solr 4.0.0 the shardHandler was initialized on the calling of 
> getShardHandlerFactory.  This code was modified and moved by revision 
> 1422728: SOLR-4204: Make SolrCloud tests more friendly to FreeBSD blackhole 2 
> environments.
>  
> We fixed our issue by using the public CoreContainer(String dir, File 
> configFile) constructor which calls the load method.
> I just wanted to make sure that people were aware of this issue and to 
> determine if it really is an issue or if having the shardHandler be null was 
> expected behavior unless someone called the load(String dir, File configFile 
> ) method.
>  
> Thank you,
>  
> Ted
>  
>  
>  
> Stack trace of error:
> org.apache.solr.client.solrj.SolrServerException: 
> org.apache.solr.client.solrj.SolrServerException: 
> java.lang.NullPointerException
>                 at 
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:223)
>                 at 
> org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
>                 at 
> org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
>                 at 
> com.cision.search.solr.ProximityQParserTest.testInit(ProximityQParserTest.java:72)
>                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>                 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown 
> Source)
>                 at java.lang.reflect.Method.invoke(Unknown Source)
>                 at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>                 at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>                 at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>                 at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>                 at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>                 at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>                 at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>                 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>                 at 
> org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>                 at 
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>                 at 
> org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>                 at 
> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>                 at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>                 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>                 at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>                 at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>                 at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>                 at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>                 at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>                 at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: org.apache.solr.client.solrj.SolrServerException: 
> java.lang.NullPointerException
>                 at 
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:155)
>                 ... 27 more
> 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)
>                 ... 27 more
>  
> ___________________________________________
> Ted Merchant 
> Developer II 
> 312-873-6667
> cision.com
> Cision. Power Your Story.
> Connect with us:
>    

Reply via email to