导致SAXException2的原因:“com.foo.Bar”的实例替换为“java.lang.Object”,但“com.foo.Bar”绑定到匿名类型

将现有的jaxb(使用jaxb1.0.1和jaxb 2.0.5)应用程序(在带有jdk5的JBoss 4.3上)迁移到jaxb 2.1.10(随jdk6提供,更新jdk1.6.0_30)。

我无法修改客户提供的架构。

我已经从Sun RI删除了jaxws20,jwsdp,jaxp和jaxb jar的所有引用,并且仅使用jdk 6提供的jar。

任何指针?

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) 

这可以通过将Foo对象添加到List类型SOAP参数来引起。

几个星期前,我有同样的例外。 我本来期望编译错误,因此必须有一些丑陋的类型强制来允许它发生。 我没有进行任何进一步的调查 – 用Bar ‘s替换Foo (他们本来应该这样做)解决了这个问题。