javaee / jaxb2-commons

JAXB Implementation project has been contributed to Eclipse Foundation. This repository is for legacy review only. Please refer to the Eclipse EE4J Metro project for the very latest
https://eclipse-ee4j.github.io/jaxb-ri/
Other
16 stars 15 forks source link

UnsupportedOperationException on copyTo method when copying xs:any sub-element #16

Closed glassfishrobot closed 16 years ago

glassfishrobot commented 16 years ago

In rim.xsd file (attached) I have the following schema:

When I use copyTo method on a JAXB generated binding instance based on instance file ExtrinsicObject_GMLEnvelopeSlot.xml (attached) I get exception below. The problem is due to org.apache.xerces.dom.ElementNSImpl not implementing a clone(0 method.

I am looking for a fix in the following code: ./basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java ./runtime/src/main/java/org/jvnet/jaxb2_commons/lang/builder/CopyBuilder.java

java.lang.UnsupportedOperationException: Could not clone the object [[gml:Envelope: null]] as invocation of the clone() method has thrown an exception. at org.jvnet.jaxb2_commons.lang.builder.CopyBuilder.copy(CopyBuilder.java:34) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:36) at org.freebxml.omar.jaxb.bindings.rim._4_0.AnyValueType.copyTo(AnyValueType.java:132) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:24) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:44) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:20) at org.freebxml.omar.jaxb.bindings.rim._4_0.ValueListType.copyTo(ValueListType.java:158) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:24) at org.freebxml.omar.jaxb.bindings.rim._4_0.SlotType.copyTo(SlotType.java:234) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:24) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:44) at org.jvnet.jaxb2_commons.lang.builder.JAXBCopyBuilder.copy(JAXBCopyBuilder.java:20) at org.freebxml.omar.jaxb.bindings.rim._4_0.ExtensibleObjectType.copyTo(ExtensibleObjectType.java:163) at org.freebxml.omar.jaxb.bindings.rim._4_0.IdentifiableType.copyTo(IdentifiableType.java:140) at org.freebxml.omar.jaxb.bindings.rim._4_0.RegistryObjectType.copyTo(RegistryObjectType.java:492) at org.freebxml.omar.jaxb.bindings.rim._4_0.ExtrinsicObjectType.copyTo(ExtrinsicObjectType.java:245) at org.freebxml.omar.jaxb.bindings.rim._4_0.ExtrinsicObjectType.copyTo(ExtrinsicObjectType.java:275) at .... Caused by: java.lang.NoSuchMethodException: org.apache.xerces.dom.ElementNSImpl.clone() at java.lang.Class.getMethod(Class.java:1605) at org.jvnet.jaxb2_commons.lang.builder.CopyBuilder.copy(CopyBuilder.java:16) ... 40 more

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 16 years ago

Reported by najmi

glassfishrobot commented 16 years ago

najmi said: Created an attachment (id=9) rim.xsd schema file

glassfishrobot commented 16 years ago

najmi said: Created an attachment (id=10) Sample instance document that causes copyTo to fail

glassfishrobot commented 16 years ago

najmi said: Created an attachment (id=11) proposed patch to fix issue

glassfishrobot commented 16 years ago

najmi said: Lexi, I have attached a patch to fix the issue. It is reliable but kludgy handling of lack of clone method in org.apache.xerces.dom.ElementNSImpl.clone().

Please comment of whether I should commit this change or not. Thanks. If I commit it we will need to do a new release to include this change. I will be counting on you for that.

glassfishrobot commented 16 years ago

lexi said: Fixed in 0.4.1.2. I've added your fix to JAXBCopyBuilder, added a test case and a new tests/issues module as a showcase for this. Works quite fine. Thank you for logging the issue and providing the fix.

glassfishrobot commented 16 years ago

File: ExtrinsicObject_GMLEnvelopeSlot.xml Attached By: najmi

glassfishrobot commented 16 years ago

File: issue-16-patch.txt Attached By: najmi

glassfishrobot commented 16 years ago

File: rim.xsd Attached By: najmi

glassfishrobot commented 16 years ago

Was assigned to lexi

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB2_COMMONS-16

glassfishrobot commented 16 years ago

Marked as fixed on Friday, November 21st 2008, 8:28:21 pm