2

I have a problem using Moxy to convert a JSON String to an XML Object. Here is the exception I get when I do this conversion:

Exception [EclipseLink-43] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing class for indicator field value [TENANT] of type [class java.lang.String].
Descriptor: XMLDescriptor(fr.niji.nates.webservices.macd.ws.COMPONENTTYPE --> [])
    at org.eclipse.persistence.exceptions.DescriptorException.missingClassForIndicatorFieldValue(DescriptorException.java:940)
    at org.eclipse.persistence.internal.oxm.QNameInheritancePolicy.classFromRow(QNameInheritancePolicy.java:278)
[...]

Here is the class COMPONENTTYPE:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "COMPONENT_TYPE")
@XmlSeeAlso({
    COMPONENTDETAILTYPE.class,
    MACDRESULTTYPE.Created.class
})
public class COMPONENTTYPE {

    @XmlAttribute(name = "type", required = true)
    protected String type;
    @XmlAttribute(name = "dbid", required = true)
    protected int dbid;

    public String getType() {
        return type;
    }

    public void setType(String value) {
        this.type = value;
    }

    public int getDbid() {
        return dbid;
    }

    public void setDbid(int value) {
        this.dbid = value;
    }
}

The problem seems to be only on "type" attribute.

Does anyone have an idea? Thanks,

  • The attribute @type is used for "classIndicatorField". So in QNameInheritancePolicy.classFromRow method, the 'lineObject indicator = rowFromDatabase.get(getClassIndicatorField());' returns a result instead of "null"... Is there a solution to ignore this ? – user2096168 Mar 08 '16 at 16:06

1 Answers1

0

The solution I found is to add the annotation @XmlDiscriminatorNode to the class :

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;

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

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "COMPONENT_TYPE")
@XmlSeeAlso({
    COMPONENTDETAILTYPE.class,
    fr.niji.nates.webservices.macd.ws.MACDRESULTTYPE.Created.class
})
@XmlDiscriminatorNode("@@type")
public class COMPONENTTYPE {
    [...]