xsd:datetime and XmlGregorianCalendar causes NullPointerException

Posted by Draemon on Stack Overflow See other posts from Stack Overflow or by Draemon
Published on 2010-03-23T17:50:44Z Indexed on 2010/03/23 17:53 UTC
Read the original article Hit count: 321

Filed under:
|
|
|
|

The following works:

public Date getDate() {
    return date;
}

and produces something like:

<date>2010-03-23T17:43:50.879Z</date>

And I can use an XmlGregorianCalendar to return xsd:date or xsd:time types fine:

@XmlSchemaType(name="date")
public XmlGregorianCalendar getDate() {
    return date;
}

which produces something like:

<date>2010-03-23</date>

But trying to return xsd:datetime like so:

@XmlSchemaType(name="datetime")
public XmlGregorianCalendar getDate() {
     return date;
}

Causes this stack trace:

java.lang.NullPointerException
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.checkXmlGregorianCalendarFieldRef(RuntimeBuiltinLeafInfoImpl.java:864)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.access$200(RuntimeBuiltinLeafInfoImpl.java:111)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.print(RuntimeBuiltinLeafInfoImpl.java:536)
...snip...
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)

Which doesn't mention my code at all.

I'm using tomcat 6.0.24, java 1.6.0_16-b01

© Stack Overflow or respective owner

Related posts about java

Related posts about tomcat