Error while unmarshalling xml

Hi All,

I am facing issue while unmarshalling an xml to create the corresponding java object

public class TestSolaceConnection {

public static void main(String[] args) {

File file = new File("BranchCustomerNotification.xml");

Unmarshaller unmarshaller;

try {

JAXBContext jaxbContext = JAXBContext.newInstance(EventMessageType.class);

unmarshaller = jaxbContext.createUnmarshaller();

EventMessageType event = (EventMessageType) unmarshaller.unmarshal(file);

EventBodyType eventBody = event.getBody();


} catch (JAXBException e) {

// TODO Auto-generated catch block





On running the above program, I am getting below error

Exception in thread "main" java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to com.db._2016.infomessagebroker.types.EventMessageType

at com.test.sp.TestSolaceConnection.main(

Read More »

By: coderanchjavageneral - 5 days ago

Related Posts