.xsd is not part of this compilation. This is a bug for .xjb

I am trying to modify the schemaLocation in my xjb file so that I do not use the remote file using the URL, but use a local copy, which is also under version control.

So, for example, my xjb file has something similar to

 <?xml version="1.0" encoding="UTF-8"?> <jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsd:ID="JaxbBindingsForWMiddleware" version="2.0"> <jxb:bindings node="/xsd:schema" schemaLocation="http://myserver:80/a/b/c/d/myxsd.xsd"> 

When I change this to a local copy, for example

 schemaLocation="../../src/main/resources/myxsd.xsd"> 

mvn clean install will complete with a message similar to

[WARNING] Called: com.sun.istack.SAXParseException2; SYSTEMID: File: / E: /somefolder/somefolder/myjavaproject/target/bindings/myxjb.xjb; lineNumber: 33; columnNumber: 33; "File: / E: /somefolder/somefolder/myjavaproject/target/bindings/mywsdl.wsdl" is not part of this compilation. Is this a bug for "File: / E: /somefolder/somefolder/myjavaproject/target/bindings/myxjb.xjb"?

I noticed that it is looking for my wsdl file in the target directory. I can manipulate schemaLocation so that it points to the src directory. Then the path exists, but the message remains.

I can also put wsdl in the target directory where java tries to find it, but in this case the message remains unchanged.

So, it seems like something specific is about to happen in order to make it part of this compilation. What needs to be done to compile it correctly?

+7
source share
5 answers

In my environment (version 2.2), it worked only when the files were in the selected folders (the schema in src / main / xsd / schema.xsd and the ind binding src / main / xsb / binding.xsb) and the associated schema binding file relative to: schemaLocation = "../xsd/schema.xsd"

It really is a seam to be fragile.

+4
source

It starts working after adding the xsd to the pom file in the plugin configuration, for example:

  <bindingDirectory> src/main/resources/binding </bindingDirectory> <bindingFiles> <bindingFile>bindings.xjb</bindingFile> <bindingFile>../xsd/egrul.xsd</bindingFile> <bindingFile>../xsd/arrays.xsd</bindingFile> </bindingFiles> 
+2
source

Considering the problem, I can suggest the following steps:

Firstly, if you use some kind of plugin to create your own stubs. I am using cxf-codegen-plugin (you can use any), an important step is locating your binding file, say, it inside \ wsdl resources
Here is a 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> 

Further, now, by executing "mvn generate-sources", maven has a view of where to look for the binding file. Suppose you also put your xsd file in the resources \ wsdl folder (you can specify any path)
Let's see the snippet snippet. Xml

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


Since you have already defined your path to the binding file in the maven plugin, and your xsd is also in this path, you do not need to define this path again in the schemaLocation of your binding file.

+1
source

I have had success with

  • Put both the schema and the bindings in src / main / resources

    Src / home / resources / myxsd.xsd

    Src / core / resources / mybindings.xjb

  • Direct your maven plugin that will run xjc to find files there

  • In the bindings file use

    SchemaLocation = "myxsd.xsd"

If you want to add some directories to src / main / resources, you can do this - you will need to determine the correct relative path to use when specifying the scheme.

0
source

I got this error at compile time because my IDE added the bin/ directory to the JAXB compilation package. This has been fixed with rm -rf BaseDirectory/bin/ or rm -rf BaseDirectory; git co BaseDirectory rm -rf BaseDirectory; git co BaseDirectory rm -rf BaseDirectory; git co BaseDirectory rm -rf BaseDirectory; git co BaseDirectory . The latter is probably better / more complete.

(Eclipse, which I rarely use, compiles the output to /bin , while IntelliJ IDEA or raw gradle compiles to /build )

0
source

All Articles