AutoroutePartHandler exception

Topics: Troubleshooting
Dec 4, 2012 at 5:48 AM

Hi! AutoroutePartHandler throws strange exception:

2012-12-04 08:09:52,501 [10] NHibernate.Util.ADOExceptionReporter - Index was outside the bounds of the array.
2012-12-04 08:09:52,548 [10] Orchard.ContentManagement.DefaultContentManager - GenericADOException thrown from IContentHandler by Orchard.Autoroute.Handlers.AutoroutePartHandler
NHibernate.Exceptions.GenericADOException: could not load an entity: [Orchard.Autoroute.Models.AutoroutePartRecord#917][SQL: SELECT autoroutep0_.Id as Id262_0_, autoroutep0_.UseCustomPattern as UseCusto2_262_0_, autoroutep0_.CustomPattern as CustomPa3_262_0_, autoroutep0_.DisplayAlias as DisplayA4_262_0_, autoroutep0_.ContentItemRecord_id as ContentI5_262_0_ FROM Orchard_Autoroute_AutoroutePartRecord autoroutep0_ WHERE autoroutep0_.Id=?] ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Iesi.Collections.Generic.DictionarySet`1.Add(T o)
   at NHibernate.AdoNet.AbstractBatcher.PrepareQueryCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
   at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters queryParameters, Boolean scroll, ISessionImplementor session)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister)
   --- End of inner exception stack trace ---
   at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister)
   at NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
   at NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session)
   at NHibernate.Event.Default.DefaultLoadEventListener.LoadFromDatasource(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
   at NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
   at Orchard.Data.Providers.AbstractDataServicesProvider.OrchardLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Providers\AbstractDataServicesProvider.cs:line 114
   at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
   at NHibernate.Impl.SessionImpl.Get(String entityName, Object id)
   at NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)
   at NHibernate.Impl.SessionImpl.Get[T](Object id)
   at Orchard.Data.Repository`1.Get(Int32 id) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Data\Repository.cs:line 87
   at Orchard.ContentManagement.Handlers.StorageFilter`1.<>c__DisplayClass1.b__0(TRecord prior) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilter.cs:line 54
   at Orchard.ContentManagement.Utilities.LazyField`1.GetValue() in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\Utilities\LazyField.cs:line 24
   at Orchard.Autoroute.Handlers.AutoroutePartHandler.<.ctor>b__5(GetContentItemMetadataContext ctx, AutoroutePart part)
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 331
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in c:\Users\sebros\My Projects\Orchard\src\Orchard\InvokeExtens

seems it fired from AutoroutePartHandler

            // Register alias as identity
            OnGetContentItemMetadata<AutoroutePart>((ctx, part) => {
                if (part.DisplayAlias != null)
                    ctx.Metadata.Identity.Add("alias", part.DisplayAlias);
            });

the question is - what does it mean and how to fix it?

Thank you

Coordinator
Dec 4, 2012 at 5:49 AM

Looks like there is a corrupt entry in the database.

Dec 4, 2012 at 6:03 AM

can I find it? or it may be better to export everything and try to import into a "clean" database?

Coordinator
Dec 4, 2012 at 7:49 AM

Should be easy to find by attaching a debugger.

Dec 5, 2012 at 5:38 AM

Thank you bertrandleroy