I am trying to get familiar with JAXB in jdeveloper. I am facing some problems. There are some test cases for which it works, for others it does not.
xml file is created manually. Respective java class for xmlelements is created manually. There is no ObjectFactory.java or jaxb.properties. Unmarshalling this xml file works fine.
xml file is not created manually. All respective java class including ObjectFactory.java and jaxb.properties are generated using jdeveloper "JAXB 2.0 Content Model from XML Schema" widget. I deleted ObjectFactory.java, jaxb.properties and package-info.java. Unmarshalling xml file with this class works fine.
Same as case 2 but this time I did not delete or modify anything generated and used as it is. It does not work. Throws the following error.
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
javax.xml.bind.UnmarshalException
- with linked exception:
[Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element rss was not found in the project]
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:816)
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:109)
at com.example.jaxbintro.JAXBExampleClass.main(JAXBExampleClass.java:36)
Caused by: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element rss was not found in the project
at org.eclipse.persistence.exceptions.XMLMarshalException.noDescriptorWithMatchingRootElement(XMLMarshalException.java:129)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshallerHandler.startElement(SAXUnmarshallerHandler.java:208)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1598)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:455)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:401)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:239)
at org.eclipse.persistence.internal.oxm.record.XMLReader.parse(XMLReader.java:157)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:688)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:271)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:258)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:218)
at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:306)
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:106)
... 1 more
The project is included in the attachment of this question. It is ready to run. More information in the comment of the java code. Main class is JAXBExampleClass.java.