Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

JAXB Unmarshaller tries to instantiate abstract class ignoring xsi:type if it is a list element #1135

Open
RenePinnow opened this issue Aug 21, 2017 · 2 comments

Comments

@RenePinnow
Copy link

JAXB ignores the xsi:type in SOAP request and tries to instantiate abstract class if the abstract element is in a list

2017-08-21 14:58:37.982 [http-nio-8080-exec-3] INFO com.sun.xml.bind.v2.ClassFactory - failed to create a new instance of class com.generali.ws.bipro.v2_6.datentypen.STEBauausfuehrung
java.lang.InstantiationException: null
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_101]
at com.sun.xml.bind.v2.ClassFactory.create0(ClassFactory.java:133) ~[jaxb-core-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.ClassFactory.create(ClassFactory.java:142) [jaxb-core-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.createInstance(UnmarshallingContext.java:687) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl$TransducerImpl.parse(RuntimeClassInfoImpl.java:392) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:69) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:589) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:338) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:216) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:185) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:415) [jaxb-impl-2.2.11.jar:2.2.11]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:394) [jaxb-impl-2.2.11.jar:2.2.11]

SOAP Request:
<sachen:Bauausfuehrung xsi:type="dt:STE_BauausfuehrungBasis">903</sachen:Bauausfuehrung>

Generated Java Code
protected List bauausfuehrung;

xsd cutouts
<xsd:element name="Bauausfuehrung" type="dt:STE_Bauausfuehrung" minOccurs="0"
maxOccurs="unbounded"/>

<xsd:complexType name="STE_Bauausfuehrung" abstract="true">
xsd:simpleContent
<xsd:extension base="xsd:string"/>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="STE_BauausfuehrungBasis" final="#all">
xsd:simpleContent
<xsd:restriction base="dt:STE_Bauausfuehrung">
<xsd:enumeration value="001">
xsd:annotation
xsd:documentation001</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="002">
xsd:annotation
xsd:documentation002</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>

@NiasSt90
Copy link

the bug applies to both "marshal" and "unmarshal".
On "marshal" the xsi:type information is lost.

i've created a reproducer project

NiasSt90 added a commit to NiasSt90/jaxb-v2 that referenced this issue Nov 8, 2017
@NiasSt90
Copy link

NiasSt90 commented Nov 8, 2017

pull request #1155 provides a fix for these issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants