Maven Jaxb Generate Fails When Compiling A Module That Depends On Multiple Modules -
i have eclipse maven project consisting of multiple modules, of contain xml schemas want generate classes (using jaxb). project layout follows:
schemas\core (pom) schemas\core\types (jar) schemas\vehicle (pom) schemas\vehicle\automobile (jar) schemas\vehicle\civic (jar)
the projects contain schemas are:
schemas\core\types (xsd\types.xsd) schemas\vehicle\automobile (xsd\automobile.xsd) schemas\vehicle\civic (xsd\civic.xsd)
some of modules contain schemas import schemas other modules:
automobile.xsd imports types.xsd civic.xsd imports types.xsd, automobile.xsd
since schemas located in different projects use classpath catalog resolver along catalog files resolve location of schemas.
the automobile project depends on schemas in types project. here entry in catalog file (catalog.xml):
<rewritesystem systemidstartstring="http://schemas/core/types/" rewriteprefix="classpath:xsd/" />
note use of classpath:xsd/ tell catalog resolver find schemas on classpath.
i use episodes prevent classes in types being re-generated inside automobile project. here snippit pom.xml:
<plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <version>0.8.3</version> <configuration> <episodes> <episode> <groupid>schemas.core</groupid> <artifactid>types</artifactid> <version>1.0-snapshot</version> </episode> <episodes> <catalog>src/main/resources/catalog.xml</catalog> <catalogresolver>org.jvnet.jaxb2.maven2.resolver.tools.classpathcatalogresolver</catalogresolver> <extension>true</extension> ....
when run mvn clean install on automobile project works file. schema types.xsd resolved on classpath , classes generated.
where run problems trying compile project civic.
the civic project depends on both types.xsd , automobile.xsd. use catalog file (catalog.xml) define location of schemas:
<rewritesystem systemidstartstring="http://schemas/core/types/" rewriteprefix="classpath:xsd/" /> <rewritesystem systemidstartstring="http://schemas/vehicle/automobile/" rewriteprefix="classpath:xsd/" />
i use episodes prevent re-generation of classes. here snippit pom.xml civic:
<plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <version>0.8.3</version> <configuration> <episodes> <episode> <groupid>schemas.core</groupid> <artifactid>types</artifactid> <version>1.0-snapshot</version> </episode> <episode> <groupid>schemas.vehicle</groupid> <artifactid>automobile</artifactid> <version>1.0-snapshot</version> </episode> </episodes> <catalog>src/main/resources/catalog.xml</catalog> <catalogresolver>org.jvnet.jaxb2.maven2.resolver.tools.classpathcatalogresolver</catalogresolver> <extension>true</extension> ...
when try run mvn clean install on civic project run problems. complains not being able resolve public/system ids. here of error messages get:
could not resolve publicid [null], systemid [jar:file:/_m2repository/schemas/vehicle/automobile/1.0-snapshot/automobile-1.0-snapshot.jar!http://schemas/core/types/types.xsd] [error] error while parsing schema(s).location []. com.sun.istack.saxparseexception2; ioexception thrown when processing "jar:file:/_m2repository/schemas/vehicle/automobile/1.0-snapshot/automobile-1.0-snapshot.jar!http://schemas/core/types/types.xsd". exception: java.net.malformedurlexception: no !/ in spec. ....
for reason cannot find types.xsd when trying parse jar file automobile project.
does know why might happening?
thank you.
note - experimenting around tying things work , did find 1 way. if remove episodes pom.xml file no longer error, however, project civic ends types dependent modules (which tying avoid using episodes).
if want see full catalog.xml , pom.xml files each project please see following links:
types: http://pastebin.com/uym3dy6x
automobile: http://pastebin.com/vqm4mpuw
civic: http://pastebin.com/egsvgwme
i have same problem. schema c imports b , a, b imports a. generating sources a, works, b fine , c malformedurlexception pops up.
i'm still investigating error workaround use systemidsuffix (oasis spec 1.1) match systemid , rewrite it. need following:
remove 'catalogresolver' element plugin configuration in poms.
replace content of catalog file 'automobile' project following:
<systemsuffix systemidsuffix="types.xsd" uri="maven:schemas.core:types!/types.xsd"/>
replace content of catalog file 'civic' project following:
<systemsuffix systemidsuffix="types.xsd" uri="maven:schemas.core:types!/types.xsd"/> <systemsuffix systemidsuffix="automobile.xsd" uri="maven:schemas.vehicle:automobile!/automobile.xsd"/>
let me know if works you.
Comments
Post a Comment