.xsd is not a part of this compilation. Is this a mistake for .xjb

It starts working after I add my xsd in pom-file in configuration of a plugin, like this:

                <bindingDirectory>
                    src/main/resources/binding
                </bindingDirectory>

                <bindingFiles>
                    <bindingFile>bindings.xjb</bindingFile>
                    <bindingFile>../xsd/egrul.xsd</bindingFile>
                    <bindingFile>../xsd/arrays.xsd</bindingFile>
                </bindingFiles>

While looking at problem, I can suggest below steps:

First, assuming you are using some plugin to generate your stubs. I use cxf-codegen-plugin( you can use any), important step is to define the location of your binding file, let's say its inside a resources\wsdl
Here is the snippet:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <configuration>
        <encoding>UTF-8</encoding>
    </configuration>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/wsdl/YOUR_WSDL_NAME.wsdl</wsdl>
                        <wsdlLocation>classpath:wsdl/YOUR_WSDL_NAME.wsdl</wsdlLocation>
                        <extraargs>
                            <extraarg>-xjc-Xts</extraarg>
                        </extraargs>
                        <bindingFiles>
                            <bindingFile>${basedir}/src/main/resources/wsdl/binding.xml</bindingFile>
                        </bindingFiles>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>

    <dependencies>
        <dependency>
            <groupId>org.apache.cxf.xjcplugins</groupId>
            <artifactId>cxf-xjc-ts</artifactId>
            <version>${cxf.version}</version>
        </dependency>
    </dependencies>
</plugin>

Next, so now while executing "mvn generate-sources", maven have idea where to look for your binding file. Let's assume that you are also putting your xsd file in resources\wsdl folder (you can have any path)
Let's see the snippet of binding.xml

<jxb:bindings schemaLocation="YOUR_XSD_FILE.xsd" node="/xs:schema">
        .....
</jxb:bindings>


Since you have already defined your binding file path in maven plugin, and your xsd are also in that path, you needn't to define this path again in schemaLocation of your binding file.


In my environment (version 2.2) it only worked when the files was in dedicated folders (schema in src/main/xsd/schema.xsd and binding ind src/main/xsb/binding.xsb) and the binding file referenced the schema relatively: schemaLocation="../xsd/schema.xsd"

It really seams to be fragile.

Tags:

Java

Xsd