If you are facing ClassCastException while unmarshaling XML using JAXB, it might be happening because unmarshalling is returning JAXBElement object.
Use below solution if JAXB unmarshaling returns JAXBElement.
JAXBContext jaxbContext = JAXBContext.newInstance("com.test.messaging");
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
JAXBElement jaxbResponse = (JAXBElement)jaxbUnmarshaller.unmarshal(file);
MessageType message = (MessageType )jaxbResponse.getValue();
No comments :
Post a Comment