Unmarshalling types with attribute sent as xsd:any type throws 
NullPointerException
-----------------------------------------------------------------------------------

                 Key: XFIRE-998
                 URL: http://jira.codehaus.org/browse/XFIRE-998
             Project: XFire
          Issue Type: Bug
          Components: JAXB 2.0
    Affects Versions: 1.2.6
         Environment: JDK 1.6, Xfire 1.2.6 with JAXB2
            Reporter: Nasly
            Assignee: Dan Diephouse


Unmarshalling xsd:any type content having elements with attributes throws 
NullPointerException. If no attribute present in data as xsd:any element, then 
unmarshalling succeeds. In the example given below if attribute "Version" in 
"BriefDescriptonX" element not present, then unmarshalling succeeds.

Error Trace is;
ava.lang.NullPointerException
at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:322)
at 
org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1020)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:82)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:402)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:380)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:208)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:142)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:333)
at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:305)
at org.codehaus.xfire.jaxb2.JaxbType.readObject(JaxbType.java:203)
at 
org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
at 
org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
at 
org.codehaus.xfire.service.binding.DocumentBinding.readMessage(DocumentBinding.java:35)
at 
org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)

Response message;
<?xml version="1.0" encoding="UTF-8"?>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Could not unmarshall type : null</faultstring>
</soap:Fault>

Sample message that's failing;
<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
   <soapenv:Body>
      <s0:PersonX Age="10"
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
          xmlns:s0="http://example";
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
          xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
         <s0:Name>TestUser</s0:Name>
         <s0:DescriptonsX>
            <s0:BriefDescriptonX Version="ver1">
               <s0:BriefDescripton>Programmer</s0:BriefDescripton>
            </s0:BriefDescriptonX>
         </s0:DescriptonsX>
      </s0:PersonX>
   </soapenv:Body>
</soapenv:Envelope>

Schema for the above message;
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.example.org"; 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
        targetNamespace="http://www.opentravel.org"; 
elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:element name="PersonX">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="Name" type="xs:string"/>
                                <xs:element ref="DescriptonsX"/>
                        </xs:sequence>
                        <xs:attribute name="Age" type="xs:int" use="optional"/>
                </xs:complexType>
        </xs:element>

        <xs:element name="DescriptonsX" type="DescriptonsTypeX"/>

        <xs:complexType name="DescriptonsTypeX">
                <xs:sequence>
                        <xs:any processContents="skip" minOccurs="0" 
maxOccurs="unbounded"/>
                </xs:sequence>
        </xs:complexType>

        <xs:element name="BriefDescriptonX">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="BriefDescripton" 
type="xs:string"/>
                        </xs:sequence>
                        <xs:attribute name="Version" type="xs:string" 
use="optional"/>
                </xs:complexType>
        </xs:element>
</xs:schema>

Thanks,
Nasly

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to