I am using the Content Delivery API to fetch a Component from the Component Presentations on a Page and then retrieve the custom meta value of the Component. I am intermittently (vary rarely once in a day) getting the following error:
Unable to cast object of type 'Java.Io.SerializableImpl' to type java.util.date
If I refresh the Page again, it works fine. I am using object cache to maintain the cache of metadata items (could that have something to do with it?)
The stack trace is as below
[InvalidCastException: Unable to cast object of type 'Java.Io.SerializableImpl]' to type 'Java.Util.Date'.] Tridion.ContentDelivery.Meta.NameValuePair.get_Value() +155 Tridion.DataAccess.Helpers.BrokerHelper.GetComponentCustomMetaValue(Int32 componentId,String KeyName,ComponentMetaFactory cmf) +318
Unfortunately I am unable to debug this as I cannot reproduce it anytime. Please advice?
public IEnumerable<KeyValuePair<string, DateTime>> GetFifteenLatestNews(TcmUri templateTcmUri, TcmUri schemaTcmUri, int publicationId)
{
//change execute entity query to execute query
var query = BrokerQueries.FifteenLatestAllPublications(templateTcmUri, schemaTcmUri, publicationId);
var result = query.ExecuteQuery();
var cmf = new ComponentMetaFactory(publicationId);
var lstObject = new List<KeyValuePair<string, DateTime>>();
foreach (var item in result)
{
var id = new TcmUri(item).ItemId;
var c = cmf.GetMeta(id);
var dat = c.CustomMeta.NameValues["IssueDate"] as NameValuePair;
if (dat != null)
lstObject.Add(new KeyValuePair<string, DateTime>(id.ToString(), Convert.ToDateTime(dat.Value)));
}
return lstObject;
}
Today we got the same type of error. The error log is as below
2013-06-10 11:07:16,488 [7] ERROR Error - Request : /about/social_impact/default.aspx Session ID : sqqep24baug2aohg05mk1np0 Exception : Java.Lang.RuntimeException Message : Source : netrtsn Detail : System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> java.lang.NullPointerException at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The error log clearly says that its a null pointer exception. The thing that i am not able to understand is why the error disappears when i refresh the page (If this is a null pointer it should throw error every time). The QA who reported the error said that she kept the browser open 4 days ago and today she hit the same page.
In cd_storage_conf of our application i found some of the obsolete entries related to metadata for which i am getting warning in the log files as well
2
013-06-21 18:08:28,053 ERROR ComponentLink - No LinkInfo is found in the bindings, could not retrieve ComponentLinkInfo
2013-06-21 18:40:25,300 WARN ConfigurationMetadataCheckLoader - Type mapping: 'BinaryVariant' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'BinaryMeta' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'ComponentMeta' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'ComponentPresentationMeta' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'ItemMeta' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'PageMeta' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'Reference' for storage: defaultdb was found, typeMapping should be 'Metadata'
2013-06-21 18:40:25,305 WARN ConfigurationMetadataCheckLoader - Type mapping: 'LinkInfo' for storage: defaultdb was found, typeMapping should be 'Metadata'
I was just wondering if that could be the reason for this issue.
new TcmUri("tcm:0-0-0")
did the trick). It was a problem with the JuggerNET initialization, which is why it worked once it was initialized.