javaee / jaxb-v2

Other
210 stars 100 forks source link

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

Open RenePinnow opened 7 years ago

RenePinnow commented 7 years ago

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:

903 **Generated Java Code** protected List bauausfuehrung; **xsd cutouts** 001 002
NiasSt90 commented 7 years ago

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

i've created a reproducer project

NiasSt90 commented 7 years ago

pull request #1155 provides a fix for these issue.