Orchard CMS 1.4.2: Autoroute error and other errors - orchardcms

I have a new Orchard CMS 1.4.2 installation that I have added a custom module to.
The custom module has 3 custom parts that are basically copies of the bodypart ContentPart.
I don't know much about the bodypart (or Orchard...), and I note that the mycustompartrecord class derives from:
ContentPartVersionRecord
One question is that I don't know why.
The other question is that running the site, I get the following error after updating the text of one of the custom "bodypart" content parts.
2012-06-02 08:15:49,580 [21] Orchard.ContentManagement.DefaultContentManager - ArgumentOutOfRangeException thrown from IContentHandler by Orchard.Autoroute.Handlers.AutoroutePartHandler
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Linq.Enumerable.ElementAt[TSource](IEnumerable`1 source, Int32 index)
at Orchard.Autoroute.Services.AutorouteService.GetDefaultPattern(String contentType)
at Orchard.Autoroute.Services.AutorouteService.GenerateAlias(AutoroutePart part)
at Orchard.Autoroute.Handlers.AutoroutePartHandler.PublishAlias(AutoroutePart part)
at Orchard.Autoroute.Handlers.AutoroutePartHandler.<.ctor>b__2(PublishContentContext ctx, AutoroutePart part)
at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter`1.Published(PublishContentContext context, TPart instance) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 156
at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Published(PublishContentContext context) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 81
at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Published(PublishContentContext context) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 274
at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass3d.<Publish>b__3b(IContentHandler handler) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 342
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\InvokeExtensions.cs:line 19
I really have no idea what is the cause of this. It seems to have no negative effect, on adding content. I suspect it is something to do with the way I am using these bodypart copies, but I am not sure.
NOTE:
As discussed in a previous thread (See details here), I have previously had another error, when using a CLEAN source code installation (ie, no modules, nothing custom) of Orchard v.1.4.2. The error is as follows:
Before installing any modules, and with a clean install, I was getting the following error:
2012-05-31 17:59:43,876 [9] NHibernate.AdoNet.AbstractBatcher - Could not execute query: SELECT this_.Id as Id13_0_, this_.SerialNumber as SerialNu2_13_0_ FROM Settings_ShellDescriptorRecord this_ WHERE 1=1
System.Data.SqlServerCe.SqlCeException (0x80004005): The specified table does not exist. [ Settings_ShellDescriptorRecord ]
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
2012-05-31 17:59:43,892 [9] NHibernate.Util.ADOExceptionReporter - The specified table does not exist. [ Settings_ShellDescriptorRecord ]
2012-05-31 17:59:43,907 [9] NHibernate.Util.ADOExceptionReporter - The specified table does not exist. [ Settings_ShellDescriptorRecord ]
The error has only appeared once in the logs, and doesn't seem to affect the system thereafter. Don't know if this is relevant to the autoroutepart error.

Unfortunately I can't answer your main question.
As for ContentPartVersionRecord: when you need a part to be versioned (i.e. saving a new copy of its content with every modification), you need to use this. BodyPart is a case of versioned content parts.
The SQL exception you're getting is I think completely harmless, as it's expected on setup. This query is used to check if the DB was already set up or not - if it fails, then not.

Related

Class Cast Exception coming while Deploying in Liferay DXP

We are getting following below error when we deploy any application in Liferay DXP 7.
When we clean the Liferay DXP and then redeploy the below issue gets fixed.
But the problem with this approach is that all the caches gets deleted after cleaning and when we redeploy and access the site , the caches gets recreated but it takes lot of time to access any page on the site.
[2018-05-17 10:58:33,113] [DEBUG] [10.111.2.74] [] [http-nio-5443-exec-8] [com.fsvps.clientPortal.service.common.ProgramFilterPopulator] - Retrieving logged in user
[2018-05-17 10:58:33,137] [DEBUG] [10.111.2.74] [] [http-nio-5443-exec-8] [com.fsvps.clientPortal.util.common.UserContextInitializationInterceptor] - Portlet mode view and debug mode = false
[2018-05-17 10:58:33,137] [DEBUG] [10.111.2.74] [] [http-nio-5443-exec-8] [com.fsvps.clientPortal.util.common.UserContextInitializationInterceptor] - Checking to see if invalid filter view should be shown
[2018-05-17 11:07:40,859] [DEBUG] [] [] [http-nio-5443-exec-2] [com.fsvps.clientPortal.util.common.UserContextInitializationInterceptor] - Entering
[2018-05-17 11:07:40,859] [WARN] [] [] [http-nio-5443-exec-2] [org.springframework.web.portlet.DispatcherPortlet] - Handler execution resulted in exception - forwarding to resolved error view
java.lang.ClassCastException: com.fsvps.clientPortal.domain.common.UserContext cannot be cast to com.fsvps.clientPortal.domain.common.UserContext
at com.fsvps.clientPortal.domain.common.UserContext$$FastClassBySpringCGLIB$$818d2483.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.fsvps.clientPortal.domain.common.UserContext$$EnhancerBySpringCGLIB$$830ac420.setIpAddress(<generated>)
at com.fsvps.clientPortal.util.common.UserContextInitializationInterceptor.preHandle(UserContextInitializationInterceptor.java:93)
at org.springframework.web.portlet.handler.HandlerInterceptorAdapter.preHandleRender(HandlerInterceptorAdapter.java:72)
at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:739)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:537)
The exact cause is impossible to pinpoint with the information you give. However, the class of problem is easy to identify:
java.lang.ClassCastException:
com.fsvps.clientPortal.domain.common.UserContext cannot be cast to
com.fsvps.clientPortal.domain.common.UserContext
(separated to lines to illustrate the identical class name)
Whenever a class can't be typecasted to itself or a legitimate superclass/interface, you're dealing with duplicate code: There are two versions of the class with the same name available to the classloader, and the system is choosing both.
As the error message just contains the name of the class, not its classloader, a first glance at the error message doesn't make sense. Knowing that a class is uniquely described by its package, name, and its classloader leads you to the root cause.
Identify your modules and make sure that there's only one option for com.fsvps.clientPortal.domain.common.UserContext available.
Edit: Answering to your comments - without knowing your deployment details, there's no way to help you other than wild guesses. Please add more information to your question if the next wild guess doesn't help:
The name of the class, UserContext, suggests that you might store it somewhere, e.g. in a session. Doing so will prevent the original class from unloading when you're undeploying your plugin. Note that there is a huge difference between undeploying code and garbage collecting objects: GC can only happen, when there is no more reference.
If you deploy an updated version of your plugin, the old and existing objects still are referencing the previously loaded UserContext class, while the new code is trying to assign it to a new UserContext reference. Even though, both might be identical in implementation, they are different classes that just share the name.
You can't keep long living references to code that might undeploy, and expect them to stay usable. A quick fix (if you're deploying OSGi modules) might be to extract stable and long-used classes into its own bundle that you won't redeploy. Or replace session stored objects (assuming that this is it) with Java runtime classes, e.g. Map of built-in types, and build a UserContext object from those types whenever you need it.

Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property names

I am using CRM2016
I created a test entity to replicate the issue
I did not do any customization on it. I created a new record with default fields and form. Then I tried to access the webapi for it
http://localhost/CRMDataBase/api/data/v8.0/new_test(bgcs0249-0a06-e611-941a-003002djlnc)
It worked fine and brought the record. Then I deleted the records and created a business process flow for it, with just one stage and one step
I activated it and added a new test record and tried to access the webapi url and it threw the below error
{ "error":{
"code":"","message":"Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property
names. All property names (Navigation and Structural property) must be
unique in an Entity ","innererror":{
"message":"Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property
names. All property names (Navigation and Structural property) must be
unique in an Entity
","type":"Microsoft.Crm.CrmHttpException","stacktrace":" at
Microsoft.Crm.Extensibility.OData.CrmODataEntityTypeSerializer.CreateSelectExpandNode(EntityInstanceContext
entityInstanceContext)\r\n at
System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object
graph, ODataWriter writer, ODataSerializerContext writeContext)\r\n
at
System.Web.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable
enumerable, IEdmTypeReference feedType, ODataWriter writer,
ODataSerializerContext writeContext)\r\n at
Microsoft.Crm.Extensibility.OData.CrmODataFeedSerializer.WriteObject(Object
graph, Type type, ODataMessageWriter messageWriter,
ODataSerializerContext writeContext)\r\n at
System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type
type, Object value, Stream writeStream, HttpContent content,
HttpContentHeaders contentHeaders)\r\n at
System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type
type, Object value, Stream writeStream, HttpContent content,
TransportContext transportContext, CancellationToken
cancellationToken)\r\n--- End of stack trace from previous location
where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()","internalexception":{
"message":"Property 'stageid' is of an unrecognized EdmPropertyKind.","type":"Microsoft.OData.Core.ODataException","stacktrace":"
at
Microsoft.OData.Core.UriParser.Parsers.SelectPathSegmentTokenBinder.ConvertNonTypeTokenToSegment(PathSegmentToken
tokenIn, IEdmModel model, IEdmStructuredType edmType, ODataUriResolver
resolver)\r\n at
Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.ProcessTokenAsPath(NonSystemToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.Visit(NonSystemToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectBinder.Bind(SelectToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.Bind(ExpandToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectExpandSemanticBinder.Bind(IEdmStructuredType
elementType, IEdmNavigationSource navigationSource, ExpandToken
expandToken, SelectToken selectToken, ODataUriParserConfiguration
configuration)\r\n at
Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()\r\n
at
Microsoft.Crm.Extensibility.OData.CrmODataEntityTypeSerializer.CreateSelectExpandNode(EntityInstanceContext
entityInstanceContext)"
}
} } }
If I delete all the records-> deactivate business process -> add new data and then check the webapi, it is working fine. But when I activate the business process and add new data I am getting the above error
P.S: I have not done any coding/customization to business process flow and the entity. But I am still getting this error
What can be done to resolve this?
Looks like a bug in Web API endpoint. Community forums also reference the same issue...
The Web API endpoint still has some limitations and it doesn't fully mimic the OrganizationService behavior so, which will be for the next version (9.x.x) so if you are stuck maybe try applying an update (and then use v8.1 in the url) as, or raise a MS Support case.
If you are still stuck, just try the same using OData / OrganizationService maybe.

NullReferenceException caused by null TermPart.As<AutoroutePart>() in Orchard CMS 1.7.2

crosspost: https://orchard.codeplex.com/discussions/474456
I'm on Orchard 1.7.2 and I get this error everywhere in my site (which I assume causes the load times to slow down):
Orchard.DisplayManagement.Implementation.DefaultDisplayManager - NullReferenceException thrown from Action`1 by System.Action`1[[Orchard.DisplayManagement.Implementation.ShapeDisplayingContext, Orchard.Framework, Version=1.7.2.0, Culture=neutral, PublicKeyToken=null]]
System.NullReferenceException: Object reference not set to an instance of an object.
So I traced the issue and found the function public string Slug within TermPart.cs (line 16).
public string Slug {
get { return this.As<AutoroutePart>().DisplayAlias; }
set { this.As<AutoroutePart>().DisplayAlias = value; }
}
I found out that this.As<AutoroutePart>() is null, and checking out the parts of the Content Item (via this.ContentItem.Parts), there is no AutoroutePart. Since it is null, a null reference exception is thrown when trying to retrieve the property DisplayAlias.
See image below:
Is this a known issue? Any workarounds? Is this what's causing my site to slow down?
Although having these exceptions definitely has an impact on performance I doubt it could cause a noticeable slowdown.
The exception is caused by Taxonomies's TermPart depending on AutoroutePart; i.e. if your content item doesn't use AutoroutePart (what should be pretty rare IMO) then you'll see this exception. Making TermPart depend on Autoroute is a questionable design decision (at least it could use IAliasAspect instead). Please open a bug report about the issue because this should be addressed somehow.
In the meantime you could attach AutoroutePart to the content type in question to get rid of the exceptions.

Projection, Queries missing in Orchard 1.4.2

I can't see the queries section the dashboard, neither can I see that as a part of Projection Page.
Has anything changed?
In logs, there is one error :
Object reference not set to an instance of an object.
at Szmyd.Orchard.Modules.Menu.Drivers.BreadcrumbsPartDriver.<>c__DisplayClass5.<Display>b__4()
at Orchard.ContentManagement.Drivers.ContentPartDriver`1.<>c__DisplayClassd.<ContentShape>b__c(BuildShapeContext ctx) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 108
at Orchard.ContentManagement.Drivers.ContentPartDriver`1.<>c__DisplayClass13.<ContentShapeImplementation>b__12(BuildShapeContext ctx) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 116
at Orchard.ContentManagement.Drivers.ContentShapeResult.ApplyImplementation(BuildShapeContext context, String displayType) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 37
at Orchard.ContentManagement.Drivers.ContentShapeResult.Apply(BuildDisplayContext context) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 21
at Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator.<>c__DisplayClassa.<BuildDisplay>b__9(IContentPartDriver driver) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\Coordinators\ContentPartDriverCoordinator.cs:line 49
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\OrchardWebsite\src\Orchard\InvokeExtensions.cs:line
I had the same issue and found out the projector module was disabled. I don't know why it was disabled but it made sense enabling it.
No, it's still there. Something else must be going on, such as a version mismatch causing an exception when loading the module. Did you check your app_data\logs folder?
I had the same issue with Queries not showing up in the Dashboard. Disabling the Autoroute module and enabling it again worked for me.

null reference exceptions when adding

I discovered SubSonic this evening, and after a little bit of playing with it and MySQL Connector versions, I finally got it to accept my connection string setting up a simple repository.
So I created a simple class, and went to town adding some data to the class then creating a repo, and trying to save the record.
All I can seem to get out of it is null exception errors when I call:
repo.Add(user);
No idea what's null though, and the error isn't very clear.
At one point, I changed the type of my ID field in my User class to a long and got another error out of SubSonic (saying it couldn't tell what field was my ID field, telling me to name it ID or put a tag on it, but it was already named ID)
I've put data in every field in the class, even those that are not required per the database, but nothing.
I spent the rest of the evening googling for information on my error, but no luck, and the documentation on the site didn't get me anywhere either.
Any idea what I'm doing wrong, or how I could possibly diagnose this?
Thanks in advance for any help...
Here's the exception details
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlConnection.get_ServerThread()
at MySql.Data.MySqlClient.MySqlConnection.Abort()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry)
at SubSonic.Query.Insert.ExecuteReader()
at SubSonic.Repository.SimpleRepository.Add[T](T item)
at gc_ss.Program.Main(String[] args) in C:\Users\Michaelm\Desktop\Subsonic_Demo\gc_ss\gc_ss\Program.cs:line 27
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Another Update
I'm noticing that if I change the class (User) and modify one of the properties, that the property changes get reflected in the database. Also if I drop the table, it gets constructed based on my Class. So the migrations part is working, it's something happening after that.
Final Update
Okay, I deleted the table, and changed the class to use a long as the ID field. Set to RunMigrations, and ran again, and it failed because of no default value for ID. I set the column in MySQL to AutoIncrement and all is working fine now. Not sure how it's different than setting it to long yesterday (unless changes weren't getting applied like I thought they were).
Anyway, so I guess this question is closed...
This is a issue with the mysql.data provider. Normally the connector would throw a meaningful exception but has an internal nullreference exception itself before that happens.
Look at my answer here: Subsonic 3.0.0.4 ActiveRecord Template for MySQL error on inserting new record
That explains how to work around that.

Resources