Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML
EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #894802] Tue, 10 July 2012 10:59 Go to next message
Markus Rechtien is currently offline Markus Rechtien
Messages: 4
Registered: July 2012
Junior Member
Hi,

I have a problem while using annotations with moxy for XML binding:
The corresponding eclipse project is attached.

It's a generic and repeating structure consisting of a root class, with containers and controls inside - each container may contain other containers and controls.
I used @XmlClassExtractor and @XmlSeeAlso annotations to control the class hierarchy, which works while unmarshaling..

Each specialized "Container" or "Control" is unmarshalled and added to the list of "Component"s of a "Container" correctly - "Component" by the way is the base class of "Containers" and "Controls".

Unfortunately the object structure is not marshalled correctly and currently I do not have any clue about that.
It would be great if someone could dig into the source (eclipselink-jar has to be attached to the classpath, everything else is contained and ready to run).

Btw. when I remove the @XmlSeeAlso annotation everything is bound to the base class (in this case Container or Control instead of Container1/Container2 or ControlA/ControlB) - which is not surprising, but then the marshalling is working. With the specialized Control/Container subclasses it's not working correctly.

Thanks in advance and best regards,
Markus
  • Attachment: examples.zip
    (Size: 7.38KB, Downloaded 92 times)
Re: EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #895040 is a reply to message #894802] Wed, 11 July 2012 09:43 Go to previous messageGo to next message
Blaise Doughan is currently offline Blaise Doughan
Messages: 163
Registered: July 2009
Senior Member

Hi Markus,

This appears to be a bug. You can use the following link to track our progress on this issue:
- http://bugs.eclipse.org/384834

Workaround

package de.dotquality.examples.jaxb.moxy.inheritance;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlSeeAlso;

import org.eclipse.persistence.oxm.annotations.XmlClassExtractor;

@XmlClassExtractor(ContainerClassExtractor.class)
@XmlSeeAlso({Container1.class, Container2.class})
public class Container extends Component {

	@XmlElements ({
		@XmlElement(name="C", type=Control.class),
		@XmlElement(name="C", type=ControlA.class),
		@XmlElement(name="C", type=ControlB.class),
		@XmlElement(name="CO", type=Container.class),
		@XmlElement(name="CO", type=Container1.class),
		@XmlElement(name="CO", type=Container2.class)
	})
	List<Component> subChildren;

}


-Blaise
Re: EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #895044 is a reply to message #895040] Wed, 11 July 2012 10:00 Go to previous messageGo to next message
Markus Rechtien is currently offline Markus Rechtien
Messages: 4
Registered: July 2012
Junior Member
Hi Blaise,

thank for this quick solution - at least it shows I'm wasn't completely wrong Smile

I'll use the workaround for now!

Best regards,
Markus
Re: EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #895347 is a reply to message #895044] Thu, 12 July 2012 10:16 Go to previous messageGo to next message
Markus Rechtien is currently offline Markus Rechtien
Messages: 4
Registered: July 2012
Junior Member
Blaise,

I've found a strange problem related to the JDK version and the workaround (no idea if this is a general problem).

When using the annotated classes with either jdk 1.6.0_14 or 1.6.0_32 the binding completely breaks in .._14 and works as expected starting with some jdk version greater .._14.

I haven't figured out yet which version the code starts to work, but when I run my code with the earlier version the
ClassExtractor
implementations are not working as expected.
The reason behind seems that calling Record.get("whatever") in
org.eclipse.persistence.descriptors.ClassExtractor.extractClassFromRow(Record, Session)

just returns null instead of the attributes value?! :-/

Is this a known problem?

Best regards,
Markus


Update: I broke it down to somewhere between jdk1.6.0_16 and jdk1.6.0_24 - where it starts to work again...

[Updated on: Thu, 12 July 2012 11:05]

Report message to a moderator

Re: EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #895422 is a reply to message #895347] Thu, 12 July 2012 15:46 Go to previous messageGo to next message
Matt MacIvor is currently offline Matt MacIvor
Messages: 14
Registered: July 2009
Junior Member
Hi Markus,

The underlying bug for the issue with @XmlElements and inheritance has been fixed and checked into EclipseLink 2.4 and Trunk streams. You should be able to get the fix in nightly builds starting with tonight's nightly.

I don't believe the issue you're seeing related to jdk version is a known issue. The call to Record.get ends up calling into org.xml.sax.Attributes.getValue(), so it's possible that there was a bug in the SAX parser that is shipped with the jdk that has since been fixed.

-Matt

Re: EclipseLink/Moxy 2.4 - some objects not marshalled after correct unmarshalling of XML [message #895478 is a reply to message #895422] Fri, 13 July 2012 04:41 Go to previous message
Markus Rechtien is currently offline Markus Rechtien
Messages: 4
Registered: July 2012
Junior Member
Yeah, I guess you're right Matt!

the problem lies here:
-----
com.sun.org.apache.xerces.internal.util.XMLAttributesImpl.getIndex(String, String)
-----
public int getIndex(String uri, String localPart) {
        for (int i = 0; i < fLength; i++) {
            Attribute attribute = fAttributes[i];
            if (attribute.name.localpart != null &&
                attribute.name.localpart.equals(localPart) &&
                ((uri==attribute.name.uri) ||
            (uri!=null && attribute.name.uri!=null && attribute.name.uri.equals(uri)))) {
                return i;
            }
        }
        return -1;
    } // getIndex(String,String):int

-----
When entering the method with a working version (of jdk/xml libs) the uri is "null" - in non working versions it is "" - i.e. empty String... the condition fails and "-1" is returned...

Thanks for your help guys!

Best regards,
Markus
Previous Topic:fail to make table
Next Topic:NOT operator is not handled properly in EclipseLink 2.4.0
Goto Forum:
  


Current Time: Thu Apr 17 00:11:27 EDT 2014

Powered by FUDForum. Page generated in 0.06097 seconds