[RESOLVED] ClassCastException [message #655595] |
Mon, 21 February 2011 21:22 |
|
Hello,
I'm trying to use EclipseLink to create a bridge between POJO and SDO DataObjects.
I followed the information at this page : http://wiki.eclipse.org/EclipseLink/Examples/SDO/JAXB
My code :
try {
javax.xml.bind.JAXBContext jaxbContext = JAXBContext
.newInstance(Note.class);
JAXBHelperContext jaxbHelperContext = new JAXBHelperContext(
jaxbContext);
jaxbHelperContext.getXSDHelper().define(getStringXSD());
Note poj = new Note();
DataObject pojoDO = jaxbHelperContext.wrap(poj);
System.out.println("POJO : " + poj);
System.out.println("SDO : " + pojoDO);
} catch (JAXBException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
The exception is throw by this line :
JAXBHelperContext jaxbHelperContext = new JAXBHelperContext(jaxbContext);
The exception is the following :
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to org.eclipse.persistence.jaxb.JAXBContext
at org.eclipse.persistence.sdo.helper.jaxb.JAXBHelperContext.<init>(JAXBHelperContext.java:122)
at org.eclipse.persistence.sdo.helper.jaxb.JAXBHelperContext.<init>(JAXBHelperContext.java:111)
at Test1.launchPOJOSDO(Test1.java:26)
at Test1.main(Test1.java:17)
I used a clean Eclipse Environment, based on JRE 1.6.
I created the JAVA_HOME and the ECLIPSELINK_HOME.
I don't understand why this exception is thrown.
Do someone know why ?
Thx in advance, and excuse me for my bad english level.
[Updated on: Tue, 22 February 2011 18:09] Report message to a moderator
|
|
|
Re: ClassCastException [message #655732 is a reply to message #655595] |
Tue, 22 February 2011 14:10 |
|
You need to ensure that you specify EclipseLink MOXy as your JAXB provider. This is done by adding a file called jaxb.properties in the same package as your model classes with the following entry:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
|
|
|
|
ClassCastException [message #716574 is a reply to message #655595] |
Wed, 17 August 2011 17:54 |
chitti babu Messages: 9 Registered: February 2011 |
Junior Member |
|
|
Hi Please help me to solve this issue,
But i am using Eclipse , jdk 6, Jboss 5, Sporing message listener. Weblogic 11g is using to send messages . Getting messages from WL Queue to my app thru some logic.
I am able to print xml messages in the console, but getting exception before unmarshal this,
Code :
JAXBContext jc = JAXBContext.newInstance("com.bopeep.gen");
Unmarshaller unmarshaller = jc.createUnmarshaller();
// unmarshall into Classes from a File
bilgMsg = (BILGMSG) unmarshaller.unmarshal( new StreamSource( new StringReader(stringMessage)));
Please see the below error and help to resolve this
Exception:
11:41:49,475 WARN [DefaultMessageListenerContainer] Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:149)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:285)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
[Updated on: Wed, 24 August 2011 16:13] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03607 seconds