10

Migrating existing jaxb (uses both jaxb1.0.1 and jaxb 2.0.5) application (on JBoss 4.3 with jdk5) to jaxb 2.1.10 (supplied with jdk6, update jdk1.6.0_30).

I cannot modify the customer-provided schema.

I have removed all references of jaxws20, jwsdp, jaxp and jaxb jars from Sun RI and am using jars provided by jdk 6 only.

Any pointers ??

Caused by: com.sun.istack.SAXException2: Instance of “com.foo.Bar” is substituting “java.lang.Object”, but “com.foo.Bar” is bound to an anonymous type com.foo.Bar@a2e3ss
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:247)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:662)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:165)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:332)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:698)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:332)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:320)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:493)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:325)
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
shon das
  • 121
  • 1
  • 5
  • If you've got nested anonymous complex types in the XSD they could be causing your issue. jaxb 1.x would allow that kind of thing without throwing an error but it seems to be an issue in jaxb 2.x. If that's the issue, I don't know of any way to deal with it outside modifying the XSD. – Durandal Jan 29 '14 at 05:17
  • @MRalwasser - Is there any information you can post that I can use to reproduce the error you are seeing so I can help debug the issue? – bdoughan Jan 29 '14 at 20:39

1 Answers1

3

This can be caused by adding Foo objects to a List<Bar> type SOAP parameter.

I had this exact same exception a couple of weeks ago. I would have expected a compilation error, so there must have been some ugly type coercion under the hood to allow it to happen. I didn't investigate any further - replacing Foo's with Bar's (which they should have been anyway) fixed the problem.

Rob Agar
  • 12,337
  • 5
  • 48
  • 63
  • 1
    Rob, I do NOT have a Foo class.....what do I change my Bar class to ? SAXException2: Instance of “com.foo.Bar” is substituting “java.lang.Object”, but “com.foo.Bar” is bound to an anonymous type com.foo.Bar@a2e3ss – shon das Feb 03 '12 at 18:32