I am trying to create a sample test application which converts an object to JaxbRepresentation. But when I try to run this, it gives me an error.
Main.java file
In my case I was able to solve the problem by changing the instantiation of the JAXBContext. It can either be instantiated with the package name or the ObjectFactory class as a parameter.
When instantiating with the package name:
com.myexample.test.ObjectFactory objectFactory = new com.myexample.test.ObjectFactory();
JAXBContext jaxbContext = JAXBContext.newInstance(objectFactoryMessageBody.getClass().getPackage().getName());
It gave the error:
"com.myexample.test" doesnt contain ObjectFactory.class or jaxb.index
No errors when instantiating with the class name:
com.myexample.test.ObjectFactory objectFactory = new com.myexample.test.ObjectFactory();
JAXBContext jaxbContext = JAXBContext.newInstance(objectFactoryMessageBody.getClass());