Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

RegisterPartialRouter - Can't Index Content In Find

Vote:
 

Hi,

We're using Commerce 9.20, and Find 12.1.

I'm trying to register a custom partial router. I have removed the line in the commerce init module which registers the default router, and I'm using this code to register the custom one:

            var referenceConverter = ServiceLocator.Current.GetInstance();
            var contentLoader = ServiceLocator.Current.GetInstance();
            var commerceRootContent = contentLoader.Get(referenceConverter.GetRootLink());

            var partialRouteHandler = context.Locate.Advanced.GetInstance();
            var hierarchicalCatalogPartialRouter = new CustomHierarchicalPartialRouter(() => SiteDefinition.Current.StartPage, commerceRootContent);
            partialRouteHandler.RegisterPartialRouter(new PartialRouter(hierarchicalCatalogPartialRouter));

Here is the router code - as you can see, it's supposed to do nothing at the moment:

    public class CustomHierarchicalPartialRouter : HierarchicalCatalogPartialRouter
    {
        private readonly IContentLoader _contentLoader;
        private readonly ILinksRepository _linksRepository;
        private readonly ReferenceConverter _referenceConverter;

        public CustomHierarchicalPartialRouter(
            Func routeStartingPoint,
            CatalogContentBase commerceRoot)
            : base(routeStartingPoint,
                commerceRoot,
                false,
                ServiceLocator.Current.GetInstance(),
                ServiceLocator.Current.GetInstance(),
                ServiceLocator.Current.GetInstance(),
                ServiceLocator.Current.GetInstance(),
                ServiceLocator.Current.GetInstance(),
                ServiceLocator.Current.GetInstance>())
        {
            this._contentLoader = ServiceLocator.Current.GetInstance();
            this._linksRepository = ServiceLocator.Current.GetInstance();
            this._referenceConverter = ServiceLocator.Current.GetInstance();
        }
        public override PartialRouteData GetPartialVirtualPath(CatalogContentBase content, string language, RouteValueDictionary routeValues, RequestContext requestContext)
        {
            return base.GetPartialVirtualPath(content, language, routeValues, requestContext);
        }
    }

I was hoping that this would have no net effect, but it does - the Find indexer stops working. I'm getting errors like this in the Find indexing job:

An exception occurred while indexing content 1073741865__CatalogContent: Exception has been thrown by the target of an invocation. (see log for more information)

When I have a look in the log as the error suggests, I get the stack trace below. Am I registering the router correctly?

Stack Trace:

System.ArgumentNullException: The provided content link does not have a value.
Parameter name: contentLink
at EPiServer.Core.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)
at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values)
at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues)
at EPiServer.Web.Routing.ContentRoute.AddVirtualPathFromSegments(StringBuilder virtualPath, RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues, Int32 lastNonDefaultIndex)
at EPiServer.Web.Routing.ContentRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
at EPiServer.Web.Routing.DefaultUrlResolver.GetUrlFromRoute(ContentReference contentReference, String language, RouteValueDictionary routeValues, RequestContext requestContext)
at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)
at EPiServer.Find.Commerce.CommerceUnifiedSearchSetUp.GetContentUrl(ContentReference contentLink)
--- 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.Delegate.DynamicInvokeImpl(Object[] args)
at EPiServer.Find.UnifiedSearch.IndexProjection.GetUrl(Object o)
at EPiServer.Find.DelegateValueProvider`2.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Api.BulkActionConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)
at EPiServer.Find.Json.Serializer.SerializeObjectsToJsonRequest(JsonSerializer serializer, IJsonRequest jsonRequest, IEnumerable values)
at EPiServer.Find.Api.BulkCommand.Execute()
at EPiServer.Find.Cms.ContentIndexer.IndexWithRetry(IContent[] contents, Int32 maxRetries)
at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 content, IndexOptions options)
at EPiServer.Find.Cms.ContentIndexer.IndexBatch(IEnumerable`1 content, Action`1 statusAction, Int32& numberOfContentErrors, Int32& indexingCount)
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: The provided content link does not have a value.
Parameter name: contentLink
at EPiServer.Core.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)
at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values)
at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues)
at EPiServer.Web.Routing.ContentRoute.AddVirtualPathFromSegments(StringBuilder virtualPath, RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues, Int32 lastNonDefaultIndex)
at EPiServer.Web.Routing.ContentRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
at EPiServer.Web.Routing.DefaultUrlResolver.GetUrlFromRoute(ContentReference contentReference, String language, RouteValueDictionary routeValues, RequestContext requestContext)
at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)
at EPiServer.Find.Commerce.CommerceUnifiedSearchSetUp.GetContentUrl(ContentReference contentLink)
--- 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.Delegate.DynamicInvokeImpl(Object[] args)
at EPiServer.Find.UnifiedSearch.IndexProjection.GetUrl(Object o)
at EPiServer.Find.DelegateValueProvider`2.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Api.BulkActionConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)
at EPiServer.Find.Json.Serializer.SerializeObjectsToJsonRequest(JsonSerializer serializer, IJsonRequest jsonRequest, IEnumerable values)
at EPiServer.Find.Api.BulkCommand.Execute()
at EPiServer.Find.Cms.ContentIndexer.IndexWithRetry(IContent[] contents, Int32 maxRetries)
at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 content, IndexOptions options)
at EPiServer.Find.Cms.ContentIndexer.IndexBatch(IEnumerable`1 content, Action`1 statusAction, Int32& numberOfContentErrors, Int32& indexingCount)

#154935
Sep 02, 2016 13:27
Vote:
 

I think this issue was caused by this bug http://world.episerver.com/support/Bug-list/bug/COM-2451

So I suppose you need to upgrade to Commerce 9.22 to make it works.

Regards,

/Q

#154942
Sep 02, 2016 16:05
Vote:
 

Thanks Quan.

I have now upgraded to Commerce 9.23 but the error is still occurring on the new version. 

Do you have any other clues as to what the cause might be, or is there some more information I can provide?

#160596
Edited, Sep 29, 2016 14:18
Vote:
 

Just to make sure - did you add the wildcard mapping to your site?

If you did - then I would suggest you to contact our developer support service for further assistance.

Regards,

/Q

#160598
Sep 29, 2016 14:26
Vote:
 

Yes, we have - OK, I will raise a ticket with support. Thanks.

#160603
Sep 29, 2016 14:50
Vote:
 

Hi!

I get the same now with the latetst Commerce and Find versions. Did you solve the problem?

Thanks!

/Kristoffer

#179443
Jun 12, 2017 17:01
Vote:
 

This might help: http://vimvq1987.com/2017/02/find-indexing-job-hierarchicalcatalogpartialrouter-note/ (Or it might not, this is just my guess for your problem)

#179444
Jun 12, 2017 17:10
Vote:
 

Perfect guess Quan!

#179452
Jun 12, 2017 22:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.