Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB generates duplicate ObjectFactory for package already in episode

Tags:

java

maven

jaxb

xjc

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?

like image 808
Lorenzo Bigagli Avatar asked Sep 17 '15 16:09

Lorenzo Bigagli


1 Answers

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.

like image 82
lexicore Avatar answered Oct 09 '22 02:10

lexicore