2.2.2 strips schemaLocation in binding files · Issue #803 · javaee/jaxb-v2 (original) (raw)

CXF tried to upgrade from 2.2.1 to 2.2.2 but has run into a problem.

When processing a WSDL, CXF binds the internal Schemas into the SchemaCompiler using a URL like:

file:/tmp/hello_world.wsdl#types1
file:/tmp/hello_world.wsdl#types2
etc... for each schema in the WSDL.

There are cases where an external binding file would like to point to those and in 2.2.1 and earlier, they could use those URL's in the schemaLocation of the binding file. With 2.2.2, the "#types1" is stipped off of the schemaLocation for all "file" URL's and an error is raised as it no longer matches and schema in the compile unit.

The problem is at line 247 of Internalizer.java. The code creates a File object and uses it's URI which would stip that off. My suggestion would be to change it to:

schemaLocation = loc.toExternalForm();
    target = forest.get(schemaLocation);
    if (target == null && loc.getProtocol().startsWith("file")) {
        File f = new File(loc.getFile());
        schemaLocation = new File(f.getCanonicalPath()).toURI().toString();
    }

so that if the original URI will find a schema, it would work. If not, use the new algorithm.

Affected Versions

[2.2.2]