The wsimport and xjc commands (Both downloaded as part of Java JDK) are ignoring the supplied jaxb binding file when the targeted wsdl/xsds are placed under some specific paths.
To reproduce this behavior, the path C:\a can be used. This directory contains the following XSD files:
nm.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="name.xsd"/>
<xs:annotation>
<xs:documentation xml:lang="en">Annotation</xs:documentation>
</xs:annotation>
<xs:element name="name" type="Name"/>
<xs:complexType name="FName">
<xs:sequence>
<xs:element name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LName">
<xs:sequence>
<xs:element name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
name.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Name">
<xs:sequence>
<xs:element name="FirstName" type="FName"/>
<xs:element name="LastName" type="LName"/>
<xs:element name="Date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
bindings.xjb:
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc">
<jxb:globalBindings generateElementProperty="false" collectionType="indexed">
<jxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="com.company.Converter.parseDate" printMethod="com.company.Converter.printDate"/>
</jxb:globalBindings>
</jxb:bindings>
The following command is used from C:\a to generate the JAXB artifacts:
xjc -b bindings.xjb nm.xsd
The binding is being ignored. The generated classes still use xs:date instead of java.util.Date and the adapter class is not getting generated. Issue is also reproducible when using wsimport with a wsdl that imports the XSD.
When renaming a to d, the binding is working as expected. Some paths work and some others do not. This seems to be random, no pattern was identified. Behavior is consistent for a given path. This was reproduced on windows 10, windows 7 and unix machines. Java version used was 1.7.0_79. The name of the bindings files does not seem to have an effect, but the name of the XSD files does.
What could be causing this issue and how can this be fixed? Why does the path affect the binding? Are there any workarounds that can help avoid this problem while ensuring the binding will not be ignored even if the path changes?
I think it is a bug in jaxb-xjc. One issue is reported for these behavior :
https://github.com/javaee/jaxb-v2/issues/1121
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With