Windows下的cxf 2.7.7无法处理dateTime元素

时间:2014-02-28 16:35:34

标签: java soap cxf

在我的wsdl中,我正在定义birthDate元素:

<xs:element minOccurs="0" name="birthDate" type="xs:dateTime"/>

肥皂封套中的这个元素存在但是空的时候会发生什么。

<birthDate></birthDate>

我收到以下异常

org.apache.cxf.interceptor.Fault: Unmarshalling Error:  

并在堆栈中进一步向下

Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.istack.SAXParseException2; lineNumber: 0; columnNumber: 0; ]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:372)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:349)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:842)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:101)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder$2.run(JAXBEncoderDecoder.java:870)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:868)
    ... 33 more
Caused by: com.sun.istack.SAXParseException2; lineNumber: 0; columnNumber: 0; 
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:691)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:687)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:585)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:559)
    at com.sun.xml.bind.v2.runtime.FilterTransducer.parse(FilterTransducer.java:84)
    at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:247)
    at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:65)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:514)
    at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:93)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:338)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:216)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:185)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:370)
    ... 39 more
Caused by: javax.xml.bind.UnmarshalException: 
 - with linked exception:
[java.lang.IllegalArgumentException: ]
    ... 53 more
Caused by: java.lang.IllegalArgumentException: 
    at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseAndSetYear(XMLGregorianCalendarImpl.java:2887)
    at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(XMLGregorianCalendarImpl.java:2773)
    at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:435)
    at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:536)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:583)
    ... 49 more

但是,只要元素不存在或设置为某种东西,即

<birthDate>1907-07-16T19:20:30</birthDate>

一切正常。

令人困惑的是,只有在Windows下工作时才会出现此问题。 Linux下没有问题。

什么可能导致这种奇怪?我该如何解决它?

谢谢。

1 个答案:

答案 0 :(得分:0)

根据this JIRA on the Apache site,其中列出了一个非常类似的例外:

  

<ns2:SUBMITDATE></ns2:SUBMITDATE>不会使其为空。这使得它成为一个空字符串,对于日期无效,JAXB在这种情况下正确抛出IllegalArgumentException。如果你想要它null,它应该是:   <ns12:SUBMITDATE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>   因此,传入的XML对于每个模式都是无效的,并且CXF / JAXB按设计工作。

不确定为什么它可以在Linux上运行,但不能在Windows上运行。