Skip to main content

xjc in ant - bindings not preventing namespaces collisions

3 replies [Last post]
cheffpj
Offline
Joined: 2005-10-14
Points: 0

I've come across a problem while trying to refactor our XJC target in an ant build script.

We are dealing with several schema files provided by external sources. These files should probably all inherit form a single schema, but they don't. Given that, we are forced to customize the bindings.

As currently written, resolving any name conflicts was handled by specifying a different package for each schema file (this seems like a kludge). The target ran an xjc task on each individual schema file, and provided the binding customization (specifically the package name) within the task itself:

In the interest of maintainability, I would like to refactor the task to be able to pick-up all of the schema files in the relevant directory and maintain the bindings in a single file. After refactoring to accomplish that goal, the task complains about name conflicts as in this excerpt:

[xjc] [ERROR] 'OrderInfoType' is already defined
[xjc] line 208 of OrderCreate.xsd
[xjc] [ERROR] (related to above error) the first definition appears here
[xjc] line 49 of OrderCancel.xsd
. . .
[xjc] [ERROR] 'OrderInfoType' is already defined
[xjc] line 146 of OrderDisconnect.xsd
[xjc] [ERROR] (related to above error) the first definition appears here
[xjc] line 153 of OrderCreate.xsd
[xjc] [ERROR] 'ServiceInfoType' is already defined
[xjc] line 164 of OrderDisconnect.xsd
[xjc] [ERROR] (related to above error) the first definition appears here
[xjc] line 208 of OrderCreate.xsd

It seems to be reading all of the schema files at once while not taking into account the binding customizations. The refactored task is provided below:

And the binding file looks like so:

You'll notice that passing in the -nv argument doens't seem to help. Please also note that there is much code already using the generated classes as they currently exist, so customizing the bindings to solve the real problem (conflicting names) would be a larger effort than I want to undertake.

Any advice would be appreciated.

Thank you (and sorry I didn't know how to get rid of the freakin' smiley faces and hard returns!!!!)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jcheyns
Offline
Joined: 2005-09-28
Points: 0

Hi cheffpj,

I had some similar errors when trying to build using hyperjaxb2 (=jaxb+hibernate) in my Eclipse. However running the same ant task at my prompt yielded no errors. Still trying to figure this one out...

A word on my errors, I get
[ERROR] 'AType' is already defined
[jaxbcommons.xjc] line 27 of Hint2.5.xsd
[jaxbcommons.xjc] [ERROR] (related to above error) the first definition appears here
[jaxbcommons.xjc] line 17 of Hint2.5.xsd

while in the xsd line 27 is the next complexType definition after AType

cheffpj
Offline
Joined: 2005-10-14
Points: 0

I should have mentioned that I filed this as an issue:

https://jaxb.dev.java.net/issues/show_bug.cgi?id=102

kohsuke
Offline
Joined: 2003-06-09
Points: 0

It might be best if you file this as an issue on http://jaxb.dev.java.net/ issue tracker.