Not sure where the issue is here; I suspect XJC but it's been driven by the jaxb2-maven-plugin
within maven
, so there's a couple of layers to unpack.
I'm compiling a folder of XSDs and it seems to be processing each file twice, once with the actual filename and once with a slightly altered filename. [This is on OSX, by the way, but I don't think it's a straight case-sensitive filesystem problem at all (as you'll see later).]
Here's the relevant part of the pom.xml
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
</configuration>
</plugin>
The src/main/resources
contains these XSDs:
ATIS_03_00_74_Local.xsd ITIS_Final_3_0_0.xsd LRMS_Final_09_07.xsd TCIP_4_0_0_Final.xsd
ATIS_Partial_03_00_74.xsd ITIS_Final_3_0_0_for_atis.xsd LRMS_Final_09_07_for_atis.xsd TCIP_4_0_0_Local.xsd
IM_03_00_38_Local.xsd ITIS_Local_for_atis.xsd LRMS_Final_09_07_for_im.xsd TMDD_Partial_0_0_0.xsd
IM_Partial_03_00_38.xsd ITIS_Local_for_im.xsd LRMS_Local_for_atis.xsd
ITIS_3_0_0_Local.xsd LRMS_09_07_Local.xsd LRMS_Local_for_im.xsd
when I run maven
, it fails on very single file with something like:
[ERROR] file:/Users/dhaskin/clients/cs/onebusaway-nyc/onebusaway-nyc-tcip-api/src/main/resources/atis_Partial_03_00_74.xsd[35,50]
org.xml.sax.SAXParseException: 'RouteRequest' is already defined
...
[ERROR] file:/Users/dhaskin/clients/cs/onebusaway-nyc/onebusaway-nyc-tcip-api/src/main/resources/ATIS_Partial_03_00_74.xsd[22,38]
org.xml.sax.SAXParseException: (related to above error) the first definition appears here
...
note that the filename in the first error doesn't even exist; it's the same as the 2nd filename (which does exist) with the first underscore-separated word transformed to lowercase (but note the second word, Partial
, is left unchanged).
Looking at maven -X
output, I'm pretty sure it's XJC itself that's doing this, but I haven't been able to determine yet how to fix it.
Note that this project is a sub-project in a larger maven
project, but I don't think that's relevant. For what it's worth, my maven
command line in the parent project is: mvn -X -U install -pl onebusaway-nyc-tcip-api
. (onebusaway-nyc-tcip-api
is this sub-project.)
This can be many many things.
import
s andinclude
s, the wrong name very probably comes from one of them. (Credit goes to Xstian).Ok, how would I address this.
Disclaimer: I am the author of maven-jaxb2-plugin and also the author/lead dev of the OGC Schemas project which compiles a huge set of GIS schemas.
src/main/resources
import
s andinclude
s if everything correctimport
s andinclude
s, I'd write a catalog file which fixes/rewrites the invalid referencesmvn -X clean install
and check the log, specificaly the schema resolution part.I did all of this in the mentioned OGC Schemas Project.
An example of how the schema resolution log may look like:
This normally sheds some light on what's happening and which schemas get loaded.
Most of the hints are applicable to jaxb2-maven-plugin as well.