cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kim (JIRA)" <>
Subject [jira] [Created] (CXF-6546) Imported XML schemas cannot be read when the file path includes "#"
Date Mon, 17 Aug 2015 12:04:45 GMT
Kim created CXF-6546:

             Summary: Imported XML schemas cannot be read when the file path includes "#"
                 Key: CXF-6546
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 3.1.2
         Environment: Windows 32 or 64 bit.
Java 1.8.
Tomcat 8.0.24.
            Reporter: Kim

I am deploying a webapp on Tomcat (8.0.24) using a multi-level context path (using the # in
the name of the war file or the context configuration file). The unpacked files therefore
end up in a folder with "#" in the path.
In this case the web application is deployed under the name {{dev#mywebservice.xml}}.

Accessing the generated WSDL works fine, but accessing the imported XML schema using the URL
specified in the WSDL's schemaLocation fails.

The WSDL imports a XML schema {{common.xsd}}:
    <xsd:import namespace="http://something/common/" schemaLocation="http://localhost:8080/dev/mywebservice/soap/MyService?xsd=common.xsd"/>

Accessing the XSD using the specified URL fails and gives this stack trace in the log:
java.lang.IllegalArgumentException: The resource path [file:/C:/SOMEFOLDER/apache-tomcat-8.0.24-DEV/webapps/dev%23mywebservice/WEB-INF/classes/wsdl/common.xsd]
is not valid
	at org.apache.catalina.webresources.StandardRoot.validate(
	at org.apache.catalina.webresources.StandardRoot.getResource(
	at org.apache.catalina.webresources.StandardRoot.getResource(
	at org.apache.catalina.core.ApplicationContext.getResourceAsStream(
	at org.apache.catalina.core.ApplicationContextFacade.getResourceAsStream(
	at org.apache.cxf.transport.servlet.ServletContextResourceResolver.getAsStream(
	at org.apache.cxf.resource.DefaultResourceManager.findResource(
	at org.apache.cxf.resource.DefaultResourceManager.getResourceAsStream(
	at org.apache.cxf.wsdl11.ResourceManagerWSDLLocator.getInputSource(
	at org.apache.cxf.wsdl11.ResourceManagerWSDLLocator.getInputSource(
	at org.apache.cxf.wsdl11.AbstractWrapperWSDLLocator.getBaseInputSource(
	at org.apache.cxf.frontend.WSDLGetUtils.readXSDDocument(
	at org.apache.cxf.frontend.WSDLGetUtils.getDocument(
I have done some debugging and found that the problem seems to be in the method 
{{org.apache.cxf.resource.URIResolver#tryFileSystem(String baseUriStr, String uriStr)}}
This method is called with parameters
baseUriStr = null
uriStr = "file:/C:/SOMEFOLDER/apache-tomcat-8.0.24-DEV/webapps/dev%23mywebservice/WEB-INF/classes/wsdl/common.xsd"

The line {{File f2 = new File(urif);}} throws an {{IllegalArgumentException}} because the
"#" (decoded from "%23") has special meaning in URIs.

Some proposed solutions:
* Catch and ignore the {{IllegalArgumentException}} from {{File(URI)}}.
* Construct "f2" using {{File(String)}} instead of {{File(URI)}}.
* Don't URLDecode the content of "orig" before creating "urif" thereby retaining "%23".

An interesting workaround for the problem is including a space in the path:
uriStr = "file:/C:/SOME%20FOLDER/apache-tomcat-8.0.24-DEV/webapps/dev%23mywebservice/WEB-INF/classes/wsdl/common.xsd"
This will succeed because the encoded space "%20" is replaced with " " causing a {{URISyntaxException}}
to the thrown, caught and ignored.

Using this "workaround" will, however, break other (unrelated) stuff in my application.

This message was sent by Atlassian JIRA

View raw message