none
Azure Service Bus throws a json exception because of the date format.

    Question

  • Hi, there~

    I got an exception when using the Azure Service Bus via Java.

    org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.util.Date from String value 'Mon, 10 Sep 2012 02:41:54 GMT': not a valid representation (error: Can not parse date "Mon, 10 Sep 2012 02:41:54 GMT": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
     at [Source: [B@3291e56b; line: 1, column: 70] (through reference chain: com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties["LockedUntilUtc"])
    at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.weirdStringException(StdDeserializationContext.java:243)
    at org.codehaus.jackson.map.deser.std.StdDeserializer._parseDate(StdDeserializer.java:577)
    at org.codehaus.jackson.map.deser.std.DateDeserializer.deserialize(DateDeserializer.java:28)
    at org.codehaus.jackson.map.deser.std.DateDeserializer.deserialize(DateDeserializer.java:19)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1935)
    at com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper.fromString(BrokerPropertiesMapper.java:31)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy.receiveMessage(ServiceBusRestProxy.java:187)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy.receiveQueueMessage(ServiceBusRestProxy.java:151)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor.receiveQueueMessage(ServiceBusExceptionProcessor.java:108)
    at maxst.photowithme.api.async.MessageReceiver.run(MessageReceiver.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    2012-09-10 11:40:53,481 ERROR [maxst.photowithme.api.async.MessageReceiver] - <Inner exception encountered!>
    java.lang.IllegalArgumentException: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.util.Date from String value 'Mon, 10 Sep 2012 02:41:54 GMT': not a valid representation (error: Can not parse date "Mon, 10 Sep 2012 02:41:54 GMT": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
     at [Source: [B@3291e56b; line: 1, column: 70] (through reference chain: com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties["LockedUntilUtc"])
    at com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper.fromString(BrokerPropertiesMapper.java:41)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy.receiveMessage(ServiceBusRestProxy.java:187)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy.receiveQueueMessage(ServiceBusRestProxy.java:151)
    at com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor.receiveQueueMessage(ServiceBusExceptionProcessor.java:108)
    at maxst.photowithme.api.async.MessageReceiver.run(MessageReceiver.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of java.util.Date from String value 'Mon, 10 Sep 2012 02:41:54 GMT': not a valid representation (error: Can not parse date "Mon, 10 Sep 2012 02:41:54 GMT": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
     at [Source: [B@3291e56b; line: 1, column: 70] (through reference chain: com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties["LockedUntilUtc"])
    at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.weirdStringException(StdDeserializationContext.java:243)
    at org.codehaus.jackson.map.deser.std.StdDeserializer._parseDate(StdDeserializer.java:577)
    at org.codehaus.jackson.map.deser.std.DateDeserializer.deserialize(DateDeserializer.java:28)
    at org.codehaus.jackson.map.deser.std.DateDeserializer.deserialize(DateDeserializer.java:19)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1935)
    at com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper.fromString(BrokerPropertiesMapper.java:31)
    ... 7 more

    I"m using the jackson 1.9.9 library.

    Please help me.

    Thanks in advance.

    Monday, September 10, 2012 4:35 AM

All replies

  • I've got the same issue. Main reason is that Jackson uses default system locale when creating SimpleDateFormat objects for parsing dates but service bus returns date formatted to string using RFC-1123 and ENGLISH locale. RFC-1123 date format contains day of the week and parser fails when your default locale is not ENGLISH and has different day of week names. Changing default locale before consuming message fixed this issue for me.

    Locale.setDefault(Locale.US);
    ReceiveMessageOptions opts = ReceiveMessageOptions.DEFAULT;
    opts.setReceiveMode(ReceiveMode.PEEK_LOCK);
    ReceiveQueueMessageResult resultQM = service.receiveQueueMessage("TestQueue", opts);

    Thursday, December 27, 2012 10:51 PM
  • Hi,

    This is a bug in the code and we are going to fix it soon. Meanwhile, to unblock you, you can use one of the following workarounds:

    1. Set your locale to UTC

    2. Set your locale to US

    3. Follow the investigation we have here and patch the code yourself since the Windows Azure Java SDK is open source.

    Thanks.

    Monday, March 18, 2013 8:36 PM
  • Just to let u know, in the latest version of Windows Azure SDK for Java, Version 0.4.2, this issue has been fixed. https://github.com/windowsazure/azure-sdk-for-java  

    Gong Cheng

    Tuesday, April 16, 2013 3:42 AM