Open jvissers opened 6 years ago
Hmmm - seems to have been reported on a different plugin as well: https://github.com/highsource/maven-jaxb2-plugin/issues/120
Tried with this copied test
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0" targetNamespace="http://java9.wtf/maven-jaxb2-plugin/no/pack"
elementFormDefault="qualified">
<xsd:annotation>
<xsd:appinfo>
<jaxb:schemaBindings>
<jaxb:package name="wtf.java9.maven_jaxb2_plugin.with.pack"/>
</jaxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType name="SimpleClassWithPackage">
<xsd:sequence>
<xsd:element name="attribute" type="xsd:string" minOccurs="1" maxOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
This results in a class being generated with a package name derived from the targetNamespace and not from the schemaBinding instruction.
Even though jaxb:schemaBindings are read, I see when I debug the plugin that this doesn't lead to any registrations of instances of "BISchemaBinding". This subsequently means that in the ClassSelector.getPackage() the lookup to get the configured package for a namespace yields nothing - but the default name created by the NameConverter.
Further analysis shows that for the above test case the SchemaBindings is registered as a BIXPluginCustomization. It has all of the information as is specified in the xsd:appinfo - but it is created with the wrong type (I think).
Another interesting link with respect to this issue: https://issues.apache.org/jira/browse/CXF-7055
FYI: Found that http://cxf.apache.org/cxf-xjc-plugin.html (version 3.2.1) - does honor schemaBindings correctly. So these guys apparently have fixed the issue.
Feel free to supply a Pull Request with an integration test here.
I encountered this bug today. With the upcoming end-of-life of Java 8, I think this bug might become a bit more critical.
I'm migrating a project to Java 9 and we're using external JAXB configuration using .xjb/.jbx files. What I'm seeing is that an external configuration file like this one:
Does not produce packages, classes as have been specified. What instead happens is that the package names and class names are only derived from information that is contained in the XSDs. As such the instructions in the binding file seem to be ignored. Mind you: when I make a syntax error on purpose in the binding file, the plugin actually does fail indicating that there is a problem in the binding file.
Am I missing something?