[ 
https://issues.apache.org/jira/browse/CXF-6546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kim updated CXF-6546:
---------------------
    Priority: Minor  (was: Major)

> Imported XML schemas cannot be read when the file path includes "#"
> -------------------------------------------------------------------
>
>                 Key: CXF-6546
>                 URL: https://issues.apache.org/jira/browse/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
>            Priority: Minor
>
> 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}}:
> {code:xml}
>     <xsd:import namespace="http://something/common/"; 
> schemaLocation="http://localhost:8080/dev/mywebservice/soap/MyService?xsd=common.xsd"/>
> {code}
> Accessing the XSD using the specified URL fails and gives this stack trace in 
> the log:
> {noformat}
> 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(StandardRoot.java:250)
>       at 
> org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
>       at 
> org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
>       at 
> org.apache.catalina.core.ApplicationContext.getResourceAsStream(ApplicationContext.java:579)
>       at 
> org.apache.catalina.core.ApplicationContextFacade.getResourceAsStream(ApplicationContextFacade.java:210)
>       at 
> org.apache.cxf.transport.servlet.ServletContextResourceResolver.getAsStream(ServletContextResourceResolver.java:54)
>       at 
> org.apache.cxf.resource.DefaultResourceManager.findResource(DefaultResourceManager.java:111)
>       at 
> org.apache.cxf.resource.DefaultResourceManager.getResourceAsStream(DefaultResourceManager.java:67)
>       at 
> org.apache.cxf.wsdl11.ResourceManagerWSDLLocator.getInputSource(ResourceManagerWSDLLocator.java:54)
>       at 
> org.apache.cxf.wsdl11.ResourceManagerWSDLLocator.getInputSource(ResourceManagerWSDLLocator.java:48)
>       at 
> org.apache.cxf.wsdl11.AbstractWrapperWSDLLocator.getBaseInputSource(AbstractWrapperWSDLLocator.java:60)
>       at 
> org.apache.cxf.frontend.WSDLGetUtils.readXSDDocument(WSDLGetUtils.java:723)
>       at 
> org.apache.cxf.frontend.WSDLGetUtils.getDocument(WSDLGetUtils.java:151)
> {noformat}
>       
> 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
> {code}
> baseUriStr = null
> uriStr = 
> "file:/C:/SOMEFOLDER/apache-tomcat-8.0.24-DEV/webapps/dev%23mywebservice/WEB-INF/classes/wsdl/common.xsd"
> {code}
> 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:
> {code}
> uriStr = 
> "file:/C:/SOME%20FOLDER/apache-tomcat-8.0.24-DEV/webapps/dev%23mywebservice/WEB-INF/classes/wsdl/common.xsd"
> {code}
> 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
(v6.3.4#6332)

Reply via email to