Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Dynamic Moxy Exception for Enum Value Conversion
Dynamic Moxy Exception for Enum Value Conversion [message #1222138] Thu, 19 December 2013 18:51 Go to next message
chandra sp is currently offline chandra spFriend
Messages: 3
Registered: December 2013
Junior Member
Hi,

I am using the eclipselink dynamic Moxy(2.5.1) to generate the classes from the XSD. While unmarshalling the XML I get the following exception

The XML used of unmarshalling is as follows

<app:Response  requestIdentifier="1234-5678-Display" result="success" ../>


The XSD definition for result is as follows

<xsd:attribute name="result" type="app:ResultValue" use="required"/>

<xsd:simpleType name="ResultValue">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="success"/>
            <xsd:enumeration value="failure"/>
		</xsd:restriction>
    </xsd:simpleType>


The Eclipselink exception is as follows

Exception [EclipseLink-116] (Eclipse Persistence Services - 2.5.1.v20130808-8c9f8b2): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [success] in field [@result].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[result-->@result]
Descriptor: XMLDescriptor(mycompany.names.xml._1._0.XMLResponse --> [])
	at org.eclipse.persistence.exceptions.DescriptorException.noFieldValueConversionToAttributeValueProvided(DescriptorException.java:1065)
	at org.eclipse.persistence.mappings.converters.ObjectTypeConverter.convertDataValueToObjectValue(ObjectTypeConverter.java:225)
	at org.eclipse.persistence.jaxb.JAXBEnumTypeConverter.convertDataValueToObjectValue(JAXBEnumTypeConverter.java:118)
	at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.convertDataValueToObjectValue(XMLDirectMapping.java:528)
	at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:296)
	at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:1)
	at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.attribute(XMLDirectMappingNodeValue.java:159)
	at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.startElement(UnmarshalRecordImpl.java:906)
	at org.eclipse.persistence.internal.oxm.record.SAXUnmarshallerHandler.startElement(SAXUnmarshallerHandler.java:356)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parseEvent(XMLStreamReaderReader.java:132)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:99)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:86)
	at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:895)
	at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:659)
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:585)
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:140)
	at EnumTestXMLJSONConverter.main(EnumTestXMLJSONConverter.java:52)


1. How can I avoid this exception without changing the XSD schema or providing external binding file?
2.Are there any properties I can pass to XJC compiler or JAXB so that I get the same behaviour as Static Moxy?
Re: Dynamic Moxy Exception for Enum Value Conversion [message #1222567 is a reply to message #1222138] Fri, 20 December 2013 19:40 Go to previous messageGo to next message
Denise Smith is currently offline Denise SmithFriend
Messages: 11
Registered: July 2009
Junior Member
Hi

I wasn't able to reproduce the issue you are seeing at first pass. Here is what I did, perhaps you can update this with what is different in your use case. Based on the partial XSD you posted I used the following as my XSD:

<xsd:schema targetNamespace="namespace1" xmlns:app="namespace1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="Response" type="app:ResponseType"/>
   
   <xsd:complexType name="ResponseType">
        <xsd:attribute name="requestIdentifier" type="xsd:string"/>
        <xsd:attribute name="result" type="app:ResultValue" use="required"/> 
   </xsd:complexType>


   <xsd:simpleType name="ResultValue">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="success"/>
            <xsd:enumeration value="failure"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>


Then my sample code is something like this:

public static void main(String[] args) throws Exception {
    InputStream xsd=Demo.class.getClassLoader().getResourceAsStream("./in.xsd");
    InputStream inxml = Demo.class.getClassLoader().getResourceAsStream("./in.xml");

    DynamicJAXBContext ctx = DynamicJAXBContextFactory.createContextFromXSD(xsd, null, Demo.class.getClassLoader(), null);
    Marshaller m = ctx.createMarshaller();
    Unmarshaller u = ctx.createUnmarshaller();
		
    Object unmarshalled = u.unmarshal(inxml);
    m.marshal(unmarshalled, System.out);
}


With the above example I don't see the exception you are getting so let me know what is different in your scenario.


Re: Dynamic Moxy Exception for Enum Value Conversion [message #1222826 is a reply to message #1222138] Sat, 21 December 2013 14:25 Go to previous messageGo to next message
chandra sp is currently offline chandra spFriend
Messages: 3
Registered: December 2013
Junior Member
Hi,

Looks like the Dynamic Moxy while marshalling and unmarshalling is expecting the enum constant(e.g. result="SUCCESS") in the input, rather than the enum value(e.g result="success"). Is this a bug in Dynamic Moxy?

EDIT
The exceptions
[severity=ERROR,message=
Exception Description: No conversion value provided for the value [success] in field [@result].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[result-->@result]
Descriptor: XMLDescriptor(base.xml._1._0.XMLResponse --> []),locator=[node=null,object=null,url=null,line=1,col=156,offset=-1]]

[severity=ERROR,message=
Exception Description: No conversion value provided for the value [fullResult] in field [ns0:searchResponse.@searchStatus].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[searchStatus-->ns0:searchResponse.@searchStatus]
Descriptor: XMLDescriptor(base.xml._1._0.SearchResponse --> [DatabaseTable(ns0:searchResponse)]),locator=[node=null,object=null,url=null,line=1,col=156,offset=-1]]




I have attached the driver code and the schemas.


Thanks
Chandra

[Updated on: Mon, 23 December 2013 11:52]

Report message to a moderator

Re: Dynamic Moxy Exception for Enum Value Conversion [message #1223563 is a reply to message #1222826] Mon, 23 December 2013 19:44 Go to previous messageGo to next message
Denise Smith is currently offline Denise SmithFriend
Messages: 11
Registered: July 2009
Junior Member
Yes it looks like this is a bug in dynamic MOXy.
I did a search of open bugs and it may be the same underlying issue as this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=421438
Re: Dynamic Moxy Exception for Enum Value Conversion [message #1223742 is a reply to message #1223563] Tue, 24 December 2013 10:22 Go to previous message
chandra sp is currently offline chandra spFriend
Messages: 3
Registered: December 2013
Junior Member
Hi,

Are there any workarounds which can be used without changing the XSD schema?

regards
Chandra
Previous Topic:[ SOLVED ]JPA Question
Next Topic:Bug or misunderstanding ?
Goto Forum:
  


Current Time: Thu Nov 23 16:45:27 GMT 2017

Powered by FUDForum. Page generated in 0.01691 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software