I'm using JAXB to generate classes for a schema that imports other schemas. I'm using maven and configured the maven-jaxb2 plugin to use dependencies as episodes, to skip generating classes for imported schemas.
Nevertheless, JAXB keeps generating the ObjectFactories for imported schemas, resulting in classloader conflicts and misbehaviour at runtime.
As a workaround, I'm using the maven-antrun-plugin to clean up those extra files. Is there a better way to avoid this issue?
Even with episodes, XJC sometimes generate some rudimentary ObjectFactory
. I know this effect and attribute it to a bug in XJC. My workaround so far was exactly the one you're applying, namely maven-antrun-plugin
with a delete
task, like here.
But if you get everything generated - despite the episodes - there might be a problem with your configuration. Make sure your episode artifact contain a valid META-INF\sun-jaxb.episode
with schemaBindings map="false"
for your package.
Disclaimer: I'm the author of the maven-jaxb2-plugin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With