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();

System.out.println(eventBody);

} catch (JAXBException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

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(TestSolaceConnection.java:39)...

Read More »

By: coderanchjavageneral - 5 days ago

Related Posts