I am trying to change schemaLocation
in my xjb
file to use not a remote file using URL but to use a local copy that 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 local copy for example
schemaLocation="../../src/main/resources/myxsd.xsd">
mvn clean install
will fail with a message similar to
[WARNING] Caused by: 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 a part of this compilation. Is this a mistake 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 the schemaLocation
in such way that it points to the src
directory. The path then exists but the message remains.
I can also put the wsdl in the target directory, where java tries to find it but in that case also, the message stays the same.
So it looks like something specific needs to happen to make it part of this compilation. What should be done to compile this in the correct way?
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.