Open highsource opened 10 years ago
No, what you want should already work.
This issue is about complex types annotated with jaxb:class/@ref
.
Where do you hang your customizaton?
This is my custom_oai_dc.xsd
:
<schema targetNamespace="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
jaxb:extensionBindingPrefixes="simplify"
>
<annotation>
<documentation>
XML Schema 2002-03-18 by Pete Johnston.
Adjusted for usage in the OAI-PMH.
Schema imports the Dublin Core elements from the DCMI schema for unqualified Dublin Core.
2002-12-19 updated to use simpledc20021212.xsd (instead of simpledc20020312.xsd)
2015-10-29 Add simplify extension for more convenient Java class generation
</documentation>
</annotation>
<import namespace="http://purl.org/dc/elements/1.1/"
schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"/>
<element name="dc" type="oai_dc:oai_dcType"/>
<complexType name="oai_dcType">
<choice minOccurs="0" maxOccurs="unbounded">
<annotation>
<appinfo>
<simplify:as-element-property/>
</appinfo>
</annotation>
<element ref="dc:title"/>
<element ref="dc:creator"/>
<element ref="dc:subject"/>
<element ref="dc:description"/>
<element ref="dc:publisher"/>
<element ref="dc:contributor"/>
<element ref="dc:date"/>
<element ref="dc:type"/>
<element ref="dc:format"/>
<element ref="dc:identifier"/>
<element ref="dc:source"/>
<element ref="dc:language"/>
<element ref="dc:relation"/>
<element ref="dc:coverage"/>
<element ref="dc:rights"/>
</choice>
</complexType>
</schema>
When packaging, I get the following exceptions:
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building harvester 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jaxb2-plugin:0.7.0:generate (default) @ harvester ---
Cannot find CatalogManager.properties
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd{32,52}].
com.sun.istack.SAXParseException2; systemId: file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd; lineNumber: 32; columnNumber: 52; compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings.
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:144)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:220)
at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182)
at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd{29,47}].
com.sun.istack.SAXParseException2; systemId: file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd; lineNumber: 29; columnNumber: 47; (the above customization is attached to the following location in the schema)
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:149)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:220)
at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182)
at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.882 s
[INFO] Finished at: 2015-10-29T17:50:12+01:00
[INFO] Final Memory: 13M/171M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.0:generate (default) on project harvester: Unable to parse input schema(s). Error messages should have been provided. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Not that in the case of a reference property, you have to customize one of thexs:elements and not the xs:choice.
So customize one of your elements.
On Thu, Oct 29, 2015 at 5:52 PM, Abdull notifications@github.com wrote:
This is my custom_oai_dc.xsd:
<schema targetNamespace="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" jaxb:extensionBindingPrefixes="simplify"
XML Schema 2002-03-18 by Pete Johnston. Adjusted for usage in the OAI-PMH. Schema imports the Dublin Core elements from the DCMI schema for unqualified Dublin Core. 2002-12-19 updated to use simpledc20021212.xsd (instead of simpledc20020312.xsd) 2015-10-29 Add simplify extension for more convenient Java class generation <import namespace="http://purl.org/dc/elements/1.1/" schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"/>
``` simplify:as-element-property/ ``` When packaging, I get the following exceptions:
$ mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building harvester 0.1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-jaxb2-plugin:0.7.0:generate (default) @ harvester --- Cannot find CatalogManager.properties [ERROR] Error while parsing schema(s).Location [ file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd{32,52}]. com.sun.istack.SAXParseException2; systemId: file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd; lineNumber: 32; columnNumber: 52; compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings. at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82) at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:144) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:220) at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241) at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182) at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98) at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180) at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114) at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [ERROR] Error while parsing schema(s).Location [ file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd{29,47}]. com.sun.istack.SAXParseException2; systemId: file:/C:/Users/huebbegt/git/dda-harvester/src/main/resources/oai_dc_extension.xsd; lineNumber: 29; columnNumber: 47; (the above customization is attached to the following location in the schema) at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82) at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:149) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:220) at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241) at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182) at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108) at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98) at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180) at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114) at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
— Reply to this email directly or view it on GitHub https://github.com/highsource/jaxb2-basics/issues/7#issuecomment-152246758 .
I tried different strategies (e.g., using an xjb file; directly annotating the XSD file etc.), but still get exceptions.
File src/main/resources/oai_dc.xsd
(untouched XML schema):
<schema targetNamespace="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<annotation>
<documentation>
XML Schema 2002-03-18 by Pete Johnston.
Adjusted for usage in the OAI-PMH.
Schema imports the Dublin Core elements from the DCMI schema for unqualified Dublin Core.
2002-12-19 updated to use simpledc20021212.xsd (instead of simpledc20020312.xsd)
</documentation>
</annotation>
<import namespace="http://purl.org/dc/elements/1.1/"
schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"/>
<element name="dc" type="oai_dc:oai_dcType"/>
<complexType name="oai_dcType">
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="dc:title"/>
<element ref="dc:creator"/>
<element ref="dc:subject"/>
<element ref="dc:description"/>
<element ref="dc:publisher"/>
<element ref="dc:contributor"/>
<element ref="dc:date"/>
<element ref="dc:type"/>
<element ref="dc:format"/>
<element ref="dc:identifier"/>
<element ref="dc:source"/>
<element ref="dc:language"/>
<element ref="dc:relation"/>
<element ref="dc:coverage"/>
<element ref="dc:rights"/>
</choice>
</complexType>
</schema>
File src/main/resources/bindings.xjb
:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
jaxb:extensionBindingPrefixes="simplify">
<jaxb:bindings schemaLocation="oai_dc.xsd" node="xs:complexType [@name='oai_dcType']/xs:choice/xs:element[@ref='dc:title']">
<simplify:as-element-property />
</jaxb:bindings>
</jaxb:bindings>
Maven output:
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building harvester 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jaxb2-plugin:0.7.0:generate (default) @ harvester ---
Cannot find CatalogManager.properties
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/some-user/git/dda-harvester/src/main/resources/bindings.xjb{8,37}].
com.sun.istack.SAXParseException2; systemId: file:/C:/Users/some-user/git/dda-harvester/src/main/resources/bindings.xjb; lineNumber: 8; columnNumber: 37; compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings.
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:144)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:240)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:222)
at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182)
at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/some-user/git/dda-harvester/src/main/resources/oai_dc.xsd{23,30}].
com.sun.istack.SAXParseException2; systemId: file:/C:/Users/some-user/git/dda-harvester/src/main/resources/oai_dc.xsd; lineNumber: 23; columnNumber: 30; (the above customization is attached to the following location in the schema)
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82)
at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:79)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:149)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check(UnusedCustomizationChecker.java:122)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:240)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.modelGroup(UnusedCustomizationChecker.java:222)
at com.sun.xml.xsom.impl.ModelGroupImpl.visit(ModelGroupImpl.java:125)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.particle(UnusedCustomizationChecker.java:241)
at com.sun.xml.xsom.impl.ParticleImpl.visit(ParticleImpl.java:124)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.complexType(UnusedCustomizationChecker.java:182)
at com.sun.xml.xsom.impl.ComplexTypeImpl.visit(ComplexTypeImpl.java:295)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:108)
at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.run(UnusedCustomizationChecker.java:98)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:180)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:114)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:415)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:630)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:258)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:134)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.848 s
[INFO] Finished at: 2015-11-02T14:49:33+01:00
[INFO] Final Memory: 14M/166M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.0:generate (default) on project harvester: Unable to parse input schema(s). Error messages should have been provided. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I have this same problem. Any solution?
Nope, but at least reproduced.
For some reason XJC does not attach customizations to these elements. I don't know, why, but it is as it is.
To work around, customize via the class, ex.:
<jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema/xs:complexType[@name='oai_dcType']">
<simplify:property name="titleOrCreatorOrSubject">
<simplify:as-element-property/>
</simplify:property>
</jaxb:bindings>
Documented: https://github.com/highsource/jaxb2-basics/wiki/JAXB2-Simplify-Plugin
But this is still NOT THIS ISSUE.
@Abdull did the workaround fix your issue? I have a similar problem.
I also struggled with the same issue, and finally I workaround it by using external conversion using https://javaee.github.io/jaxb-v2/
Is this issue for cases such as:
?
My use case is generating better Java classes for the OAI DC schema (better Java classes than those I get from the plain
xjc
command).I have tried the simplify plugin by editing/annotating that OAI DC schema. But during the Maven build, I get Exceptions telling me that I'm using the simplify annotations at the wrong location.