Can't get the MVC example to work!

Mar 11, 2009 at 4:04 PM
Hey,
After hours and hours of playing around with the MVC example, I finally give up.
The last error I ended up with was complaining about not being able to convert the n2_item DB entry to type ContentItem. (or words to this effect!)

I run the C# example on a blank DB, and set up the root and startup page. So effectively there is only one entry in the DB.
I restarted the C# example, and it works fine.
I then configured this DB in the MVC example, but I get the error above.

My gut instinct is that getting N2 to work in an MVC environment is always going to be a bit of a hack, and so I am shying away from it.

I'm looking into Oxite at the minute. Probably lacks a lot of the bells and whistles of other CMS systems, but I think it has a very solid and clean base that I can plug further functionality into.

Cathal.
Coordinator
Mar 11, 2009 at 9:25 PM
Could you post the exact stack trace you are experiencing? Did you download the MVC example on the release tab?

Anyway, oxite might be the right choice for you. It's more adherent to the MVC model. N2 adapts the content hierarchy on top of the MVC routing which might be a bit tricky.
Mar 11, 2009 at 10:16 PM
Hey,
>>Anyway, oxite might be the right choice for you. It's more adherent to the MVC model. N2 adapts the content hierarchy on top of the MVC routing which might be a bit tricky

You put it very well - this is what I think also. If using web forms then N2 provides a nice system that's accessible by end-users (the overall goal afterall). E.g. with Oxite there isn't even a wysiwyg, so certainly depending on the project criteria, there's a fair bit of work to do!

Cheers,
Cathal.

Error:
Object with id: 4 was not of the specified subclass: N2.ContentItem (Discriminator was: 'PageItem')
Trace:
[WrongClassException: Object with id: 4 was not of the specified subclass: N2.ContentItem (Discriminator was: 'PageItem')] NHibernate.Loader.Loader.GetInstanceClass(IDataReader rs, Int32 i, ILoadable persister, Object id, ISessionImplementor session) +300 NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session) +114 NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session) +464 NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +439 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +1010 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +114 NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister) +493 NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId) +82 NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session) +54 NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session) +206 NHibernate.Event.Default.DefaultLoadEventListener.LoadFromDatasource(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +133 NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +948 NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +436 NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +236 NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) +1302 NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +125 NHibernate.Impl.SessionImpl.Load(Type clazz, Object id) +258 NHibernate.Impl.SessionImpl.Load(Object id) +91 N2.Persistence.NH.NHRepository`2.Load(TKey id) +174 N2.Web.UrlParser.get_StartPage() +78 N2.Web.UrlParser.ResolvePath(String url) +489 N2.Web.CachingUrlParserDecorator.ResolvePath(String url) +132 N2.Web.Mvc.ContentRoute.GetRouteData(HttpContextBase httpContext) +186 MvcTest.Default.GetRouteData(HttpContextBase context) in c:\Users\Chewy\Downloads\Development\CMS\N2\Example_Mvc\wwwroot\Default.aspx.cs:31 MvcTest.Default.OnInit(EventArgs args) in c:\Users\Chewy\Downloads\Development\CMS\N2\Example_Mvc\wwwroot\Default.aspx.cs:22 System.Web.UI.Control.InitRecursive(Control namingContainer) +333 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378
Coordinator
Mar 12, 2009 at 6:25 PM
Edited Mar 12, 2009 at 6:26 PM
From the error it looks like the database contains a type that is no longer loaded. This typicall happens when a content item class is removed somehow. It's possible to diagnose available content items through /edit/install/diagnose.aspx (this isn't directly related to the mvc example)