So as the title implies, Im working in a project in which after I call an API, this API will setup an Web-Service call, after the API calls the WS then it will send back (to my own app) the response. I need to log the response as XML. So after some searching I endup with code:
Marshaller marshaller = JAXBContext.newInstance(
vhu.ReqDeclareObject.class
).createMarshaller();
My App <-> API <-> WS
POM (dependency containing the VHU package):
<dependency>
<groupId>com.some.api</groupId>
<artifactId>api</artifactId>
<version>1.1.1-SNAPSHOT</version>
</dependency>
The API has the JAXB generated classes (in VHU package) which I need to be able to marshal in my own project.
The problem is the the JAXB generated classes are in a dependency (com.some.dependency:vhu). And when I run the code Im getting this error:
vhu.ReqDeclaredObject$JaxbAccessorF_control cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor
I did a simple test trying to understand the error. I copy all the JAXB generated classes into my project and run the same code as above but this time the packaged is in my own project.
Marshaller marshaller = JAXBContext.newInstance(
ReqDeclareObject.class
).createMarshaller();
Here the application runs good.
Coping all the JAXB generated classes into the project is no viable long term solution. I need to be able to create a marshaller without bring all the classes into the project.
Thank you for your help.