以下工作:XSD:datetime和的XMLGregorianCalendar導致NullPointerException異常
public Date getDate() {
return date;
}
,併產生類似:
<date>2010-03-23T17:43:50.879Z</date>
而且我可以使用的XMLGregorianCalendar返回XSD:日期或XSD:時間類型細:
@XmlSchemaType(name="date")
public XmlGregorianCalendar getDate() {
return date;
}
它產生類似於:
<date>2010-03-23</date>
但試圖返回的xsd:日期時間,像這樣:
@XmlSchemaType(name="datetime")
public XmlGregorianCalendar getDate() {
return date;
}
原因該堆棧跟蹤:
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)
沒有提及我的代碼在所有。
我使用Tomcat 6.0.24,JAVA 1.6.0_16-B01