Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date/DateTime object type in AmbientDataFramework

Tags:

tridion

I'm having a bit of an issue with the Date (java) / DateTime (.net) type when using the Ambient Data Framework in SDL Tridion 2009.

I'm setting a claim value in java like this:

Date myDate = rs.getDate("DATE_FIELD_IN_DB");
store.put(CLAIM_URI_DATE, myDate);

This is great and life is fantastic :)

In my web application (which is .net) I need to get this value from the claim store, when I try to do so, it fails:

My code is:

if (_store.Contains(new Uri("taf:claim:company:date"))) {
  DateTime claimdata = _store.Get<DateTime>("taf:claim:company:date"); 
  Response.Write(claimdata.ToString());
}

And the error message is:

[RuntimeException] Codemesh.JuggerNET.NTypeValue.Throw(Int64 inst) +373 Codemesh.JuggerNET.JavaClass.ThrowTypedException(Int64 inst) +1365 Codemesh.JuggerNET.JavaMethod.CallInt(JavaProxy jpo) +233 Tridion.ContentDelivery.AmbientData.JuggerNetTypeHelper.FromProxyObject(Object proxyObject) +738
Tridion.ContentDelivery.AmbientData.ClaimStore.Get(Uri claimUri) +109

I've also tried obtaining as an object, which i then cast to DateTime. I'm obviously making a really basic error here, any help would be greatly appreciated.

I have also read the SDL documentation here : http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/concept_26FDE76C277D43F893175E512EFDF09A which shows the java Data object is converted to the .net DateTime.

Thanks

John

UPDATE

As per the suggestions of Peter, i've check and ensured the correct jar files are in place.

It might be worth mentioning that the date is stored in a SQL database as a 'Date' type, a typical value doesn't include a timestamp, for example '2011-09-03'. Still this all functions great in Java and I can work with the value as a date. Still when getting the value in .Net the typed exception is thrown.

like image 251
johnwinter Avatar asked Jul 12 '12 12:07

johnwinter


2 Answers

It should convert it automatically. Are you sure you are not using a different Date object than java.util.Date, though? There's quite a few of them out there...

If you really cannot get it to work, you can work around it by storing the date as a string (in ISO 8601 format) and then using DateTime.Parse on the .NET side.

But like I said: it normally works fine so there's probably something else going wrong.

Is your ADF working fine for other things in .NET? Maybe it's missing a setup step for the .NET side of things...

like image 141
Peter Kjaer Avatar answered Nov 06 '22 12:11

Peter Kjaer


A bit of a long shot, but can you verify that the right JDBC driver is installed as mentioned in this question/answer?

Exception loading CustomMeta from Tridion Broker Service (2009 SP1)

The Date value, does it contain the time? Can you ensure that it does when you get the value from the store?

like image 28
Arjen Stobbe Avatar answered Nov 06 '22 12:11

Arjen Stobbe