After upgrading to Sitecore 7.2 we got the following exception when trying to build our custom indexes:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.Reset() at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken) at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.Rebuild() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at (Object , Object[] ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Jobs.Job.ThreadEntry(Object state)
The resolution to this is quite simple. Sitecore has included <initializeOnAdd> to the index configuration. If this field is missing in the configuration, building the index fails. Just make sure you have the following line to your custom index configuration:
<myCustomIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider"> <indexAllFields>true</indexAllFields> <!-- Needed since SC7.2 --> <initializeOnAdd>true</initializeOnAdd> ....
One response to “NullReferenceException in custom Index after upgrading to Sitecore 7.2”
Thanks! Probably saved me hours of investigation.