Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAXB SchemaBinding instruction is ignored #104

Open
jvissers opened this issue Feb 22, 2018 · 8 comments
Open

JAXB SchemaBinding instruction is ignored #104

jvissers opened this issue Feb 22, 2018 · 8 comments
Assignees
Labels

Comments

@jvissers
Copy link

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:

<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<jaxb:bindings schemaLocation="../xsd/TaskData.xsd">
        <jaxb:schemaBindings>
            <jaxb:package name="com.common.oxm.taskdata"/>
            <jaxb:nameXmlTransform>
                <jaxb:typeName suffix="XMLType"/>
                <jaxb:elementName suffix="XMLElement"/>
                <jaxb:anonymousTypeName suffix="XMLInnerType"/>
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>    
</jaxb:bindings>

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?

@jvissers
Copy link
Author

Hmmm - seems to have been reported on a different plugin as well:
highsource/jaxb-tools#120

@jvissers
Copy link
Author

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.

@jvissers jvissers changed the title JAXB Binding file instruction seem to be ignored JAXB SchemaBinding instruction is ignored Feb 22, 2018
@jvissers
Copy link
Author

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.

@jvissers
Copy link
Author

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).

@jvissers
Copy link
Author

Another interesting link with respect to this issue:
https://issues.apache.org/jira/browse/CXF-7055

@jvissers
Copy link
Author

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.

@lennartj lennartj self-assigned this Mar 5, 2018
@lennartj lennartj added the bug label Mar 5, 2018
@lennartj
Copy link
Member

lennartj commented Mar 5, 2018

Feel free to supply a Pull Request with an integration test here.

@ostecke
Copy link

ostecke commented Nov 15, 2018

I encountered this bug today. With the upcoming end-of-life of Java 8, I think this bug might become a bit more critical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants