12

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.

6
  • 4
    Check the Broker database for that entry in the CUSTOM_META table. The date value might be empty, or something thats not parsable as date is trying to get parsed. Can you also post some code to see what you're doing exactly?
    – Raimond
    May 27, 2013 at 9:39
  • Can you please also tag the question with the version you're using?
    – Nuno Linhares
    May 27, 2013 at 13:04
  • In case the database has incorrect value, it should not work at all, but when i refresh the page next time it works well. I have also enabled tridion caching. Has it something to do with it? I have added the code snippet May 28, 2013 at 10:18
  • Well, obviously the dat variable is not null, so something must be in it. Can you simply log the value to see that? If it is a date, then start looking into what gets cached to see if that is the culprit.
    – Raimond
    May 29, 2013 at 8:20
  • 1
    Is it possible that the first CD API call you make is to a static method? I had a problem with that which was solved by making sure I first call a non-static method (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. Jun 24, 2013 at 12:54

5 Answers 5

8
+25

If its not happening when you refresh the page, it seems likely that a cache somewhere is masking the issue. Without being able to see the whole code of your web app, I would suggest that if you are unable to reproduce it and debug that you put the line of code that seems to be the culprit:

lstObject.Add(new KeyValuePair<string, DateTime>(id.ToString(), Convert.ToDateTime(dat.Value)));`

into a try/catch block, and log something about the id of the item that is causing the error if an exception is raised. That way you will:

  1. Not have errors in your application
  2. Have more information to start digging deeper

Perhaps there is some rogue data in the broker DB? It seems pretty clear from the error that the IssueDate field sometimes doesn't have a valid date. Have you run a query on the broker DB, along the lines of:

SELECT * FROM CUSTOM_META WHERE KEY_NAME='IssueDate' 
AND (KEY_DATE_VALUE IS NULL OR KEY_STRING_VALUE IS NOT NULL 
        OR KEY_FLOAT_VALUE IS NOT NULL)
1
  • Thanks Will, I already queried the custom_meta and didn't find any rogue data. However i am using object cache in the application. By any chance is it possible that sometimes this cache throw an error which get absorbed and then a new error of typecasting surface to the output Jun 24, 2013 at 14:52
5

This might sound crazy, but i'd check if you are using Are you using Java 1.6? But in your website / application you are accidentally using the JDBC driver for Java 1.5?

I had a similar issue to this, the problem and resolution is here: https://stackoverflow.com/questions/11452177/date-datetime-object-type-in-ambientdataframework

3

If there are not any rogue data as indicated by @Will Price, I would suggest the following to try and isolate some the issue.

  • Have you tried to disable the output cache for your application? If you have a CDN in your infrastructure, I would disable it for this domain as well.
  • Does your application maintain user personalization outside tridion OOTB capability? It might be worthwhile looking at this code as well.
  • Have you seen this issue occur during publishing of the metadata? It could be that the application is trying to access the metadata during the committing phase of the publishing process.

I hope it helps!

2

from the log, it seems issue is not related to Content Delivery. it could be related to asp.net hidden fields and eventvalidation, Please check following links

It can help.

1
  • 3
    Don't think thats true, as the stacktrace clearly shows: Java.Lang.RuntimeException Message : Source : netrtsn Detail : System.Web.HttpUnhandledException (0x80004005):
    – Raimond
    Jun 10, 2013 at 9:51
1

I have no clue what is going on, but I can give you hints that might help you find the problem.

  1. To help increase the testability, have you tried disabling the Tridion Broker Cache in the cd_storage_conf? Without broker cache active, the query should misfire every time because the results should not get cached.

  2. Your code runs a broker query. It might be that the items it hits influence the occurence of the bug.

  3. If you have lots of time to spend, are out of options, and you have a reproducable error, you could try to reproduce the occurence in Java. Then you can use a Java debugger to see what happens inside of the Tridion core, perhaps leading you to rogue data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.