Error while unmarshalling the java object.

Hello All,

I am facing issue while unmarshalling the xml file using below code

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

}

}

}

Getting following error while running the code

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)

The xml file is





 

    10261219-3902-4028-a268-220032210733

    2018-10-26T12:19:39.027

    update

    pd

    002

    branchCustomer

    6159874264

    comm

    5806353000400

    2018-10-26T12:18:34.658943

    1

 


 

   

     

       

         ...

Read More »

By: coderanchjavageneral - Friday, 9 November

Related Posts