Error- for calling BuildSolrCoreAdmin function

64 views
Skip to first unread message

Kasturi Chavan

unread,
Sep 26, 2015, 6:32:21 AM9/26/15
to SolrNet
I need to do swapping of my cores and hence need to set the SolrCoreAdmin in my solrFacility, so i can use it throughout my application using my windsor container.

When I do the following :

var solrFacility = new SolrNetFacility(ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress);

solrFacility.AddCore(AgentsIndex.IndexName, typeof(AgentsIndexMapper), ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress +"/"+ AgentsIndex.IndexName);
solrFacility.AddCore(AgentsIndex.SwapIndexName, typeof(AgentsIndexMapper), ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress + "/" + AgentsIndex.SwapIndexName);
solrFacility.BuildCoreAdmin(ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress);
_WindsorContainer.AddFacility("solr", solrFacility);


I get following error:


[NullReferenceException: Object reference not set to an instance of an object.]
   Castle.Facilities.SolrNetIntegration.SolrNetFacility.BuildCoreAdmin(ISolrConnection conn) +40

How do i solve this? im new to solrnet and need your help. Thanking you.

Regards,
Kasturi Chavan

Mauricio Scheffer

unread,
Sep 28, 2015, 5:14:53 AM9/28/15
to SolrNet
Hi,

What version of SolrNet / SolrNet.Windsor are you using?
Also, the NuGet packages include the PDB so you should get the exact line number for the exception... can you double-check that you have the PDB in place, then post back here the entire stack trace?

Cheers

Kasturi Chavan

unread,
Sep 28, 2015, 10:38:38 AM9/28/15
to SolrNet
The castle windsor version is 3.3.0 and Solnet.dll is 0.4.0.2002. The pdb are in place.  Also the solrnet.dll is externally acquired through the sitecore.contentsearch.solr.dll Dont have pdbs for that specifically.

the stack trace is 

[NullReferenceException: Object reference not set to an instance of an object.]
   Castle.Facilities.SolrNetIntegration.SolrNetFacility.BuildCoreAdmin(ISolrConnection conn) +40
   Collette.Web.MvcApplication.InitiateSolrStuff() in c:\Source-Git\Collette.com\collette-com\web\Collette.Web\Global.asax.cs:85
   Collette.Web.MvcApplication.Application_Start() in c:\Source-Git\Collette.com\collette-com\web\Collette.Web\Global.asax.cs:72

[HttpException (0x80004005): Object reference not set to an instance of an object.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12601645
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Object reference not set to an instance of an object.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618692
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458309

Mauricio Scheffer

unread,
Sep 28, 2015, 10:43:54 AM9/28/15
to sol...@googlegroups.com
0.4.0.2002 from nuget is rather old and most likely doesn't work with Windsor 3.3.0. Try upgrading to the latest version.


--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/d/optout.

Kasturi Chavan

unread,
Sep 28, 2015, 10:48:58 AM9/28/15
to SolrNet
Also using .net reflector, i checked the code for buildCoreAdmin function

public ISolrCoreAdmin BuildCoreAdmin(ISolrConnection conn)
{
    return new SolrCoreAdmin(conn, base.Kernel.Resolve<ISolrHeaderResponseParser>(), base.Kernel.Resolve<ISolrStatusResponseParser>());
}
  
public SolrCoreAdmin(ISolrConnection connection, ISolrHeaderResponseParser headerParser, ISolrStatusResponseParser resultParser)
{
    this.connection = connection;
    this.headerParser = headerParser;
    this.resultParser = resultParser;
}

In this scenario in guessing the only Object not set to refernce can be base.Kernel . Do we need to set it explicitly?

Mauricio Scheffer

unread,
Sep 28, 2015, 10:51:43 AM9/28/15
to sol...@googlegroups.com
The kernel reference in a Windsor facility is assigned by Windsor itself, so you should *not* set it explicitly ever.


--
Mauricio

--

Kasturi Chavan

unread,
Sep 28, 2015, 6:10:28 PM9/28/15
to SolrNet

I got the solution for this. I was doing it wrong. Thought of posting the answer so it helps others.

When initilaizing the solrnetfacility , the solrcoreadmin are also initialised. I later added this solrnetfacility to my container (castle windsor in this case) so i can use it over entire application.

Later when i wanted to swap the indexes after rebuild, i just resolved it 
ISolrCoreAdmin _ISolrCoreAdmin = c.GetContainer().Resolve<ISolrCoreAdmin>();
ResponseHeader response = _ISolrCoreAdmin.Swap(corename, othername);

And all set!
Hope it helps someone. Thanks a lot for all help provided.
Reply all
Reply to author
Forward
0 new messages