Why does changing the package name passed to XJC break JAXB generation?

CarSevaales

New Member
I'm using XJC to generate Java classes from the HTNG Payment Systems schemas, available in the /schemas directory of this zip.If I run XJC without passing the \[code\]-p\[/code\] parameter, generation works fine, and classes are generated under the \[code\]org.htng._2009b\[/code\] package:\[code\]$ cd schemas$ xjc -mark-generated -no-header -target 2.1 -npa .\[/code\]All I want to do is change the package name of the generated classes to something more project appropriate, e.g. \[code\]com.justin.htng\[/code\]:\[code\]$ cd schemas$ xjc -mark-generated -no-header -target 2.1 -npa -p com.justin.htng .\[/code\]However, doing this breaks JAXB generation spectacularly, throwing collision errors on almost every element. I can work around this by generating the classes via the first method, and then refactoring them to the \[code\]com.justin.htng\[/code\] package, but that's not very maintainable and doesn't port well to the maven-jaxb2-plugin. Can someone explain why this is happening, and if there is a way to work around it with XJC? I feel like if JAXB works via the first method, it should work via the second, since all that needs to be done is a simple String substitution for the package name. I suppose I could use the second method and handle all of the collisions via an .xjb bindings file, but that would be tedious given the number of errors.
 
Back
Top