You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Olivier Costet (Created) (JIRA)" <ji...@apache.org> on 2011/10/26 13:19:33 UTC

[jira] [Created] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

[JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
-------------------------------------------------------------------------------------------

                 Key: CXF-3884
                 URL: https://issues.apache.org/jira/browse/CXF-3884
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 2.4.3
            Reporter: Olivier Costet


Hi,

I believe there is a bug in
org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).

That method goes through the classloader hierarchy trying to find
classpath components. Among others, it checks the resource URLs returned
by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
file.

However, its handling of the URLs is incorrect and fails if it
encounters a URL-encoded file path, for instance:
 file:/C:/Program%20Files/Crapware/etc.

The code is:

URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
file = new File(uri.getPath()); 


This doesn't work. The java.net.URI c'tor used here *escapes* characters
as necessary.

Correct code would use:

URI uri = new URI(url.toString());
file = new File(uri.getPath());

or

URI uri = new URI(url.getProtocol(), null,
URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
file = new File(uri.getPath()); 

-.-

-Use case and why it fails-

My code, running in an application container, creates a client using the
DynamicClientFactory from some WSDL. 

That WSDL declares some (simple) types.

Those types are bound (via JAXB) to Java types that are part of my
application.

Code generation works fine, creating Adapters from the basic types to
the bound types.

But #setupClasspath() fails to find my application's JARs, because
they're loaded by the application classloader, a URLClassLoader, and are
on a path containing a space.

Consequently, the generated files cannot be compiled, because the bound
Java types cannot be resolved.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Olivier Costet (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olivier Costet updated CXF-3884:
--------------------------------

    Description: 
Hi,

I believe there is a bug in
org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).

That method goes through the classloader hierarchy trying to find
classpath components. Among others, it checks the resource URLs returned
by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
file.

However, its handling of the URLs is incorrect and fails if it
encounters a URL-encoded file path, for instance:
 file:/C:/Program%20Files/Crapware/etc.

The code is:

URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
file = new File(uri.getPath()); 


This doesn't work. The java.net.URI c'tor used here *escapes* characters
as necessary.

Correct code would use:

URI uri = new URI(url.toString());
file = new File(uri.getPath());

or

URI uri = new URI(url.getProtocol(), null,
URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
file = new File(uri.getPath()); 

-.-

_Use case and why it fails_

My code, running in an application container, creates a client using the
DynamicClientFactory from some WSDL. 

That WSDL declares some (simple) types.

Those types are bound (via JAXB) to Java types that are part of my
application.

Code generation works fine, creating Adapters from the basic types to
the bound types.

But #setupClasspath() fails to find my application's JARs, because
they're loaded by the application classloader, a URLClassLoader, and are
on a path containing a space.

Consequently, the generated files cannot be compiled, because the bound
Java types cannot be resolved.


  was:
Hi,

I believe there is a bug in
org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).

That method goes through the classloader hierarchy trying to find
classpath components. Among others, it checks the resource URLs returned
by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
file.

However, its handling of the URLs is incorrect and fails if it
encounters a URL-encoded file path, for instance:
 file:/C:/Program%20Files/Crapware/etc.

The code is:

URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
file = new File(uri.getPath()); 


This doesn't work. The java.net.URI c'tor used here *escapes* characters
as necessary.

Correct code would use:

URI uri = new URI(url.toString());
file = new File(uri.getPath());

or

URI uri = new URI(url.getProtocol(), null,
URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
file = new File(uri.getPath()); 

-.-

-Use case and why it fails-

My code, running in an application container, creates a client using the
DynamicClientFactory from some WSDL. 

That WSDL declares some (simple) types.

Those types are bound (via JAXB) to Java types that are part of my
application.

Code generation works fine, creating Adapters from the basic types to
the bound types.

But #setupClasspath() fails to find my application's JARs, because
they're loaded by the application classloader, a URLClassLoader, and are
on a path containing a space.

Consequently, the generated files cannot be compiled, because the bound
Java types cannot be resolved.


    
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> _Use case and why it fails_
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Daniel Kulp (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp updated CXF-3884:
-----------------------------

    Fix Version/s: 2.4.4
                   2.3.8
    
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>            Assignee: Aki Yoshida
>             Fix For: 2.3.8, 2.4.4
>
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> _Use case and why it fails_
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Aki Yoshida (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aki Yoshida reassigned CXF-3884:
--------------------------------

    Assignee: Aki Yoshida
    
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>            Assignee: Aki Yoshida
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> _Use case and why it fails_
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Olivier Costet (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13135873#comment-13135873 ] 

Olivier Costet commented on CXF-3884:
-------------------------------------

Comment from Aki Yoshida <el...@googlemail.com>:

Instead of going over URI, I think the code could simply use the
URLDecoder.decode(url.getPath(), "utf-8") in the File's constructor
after checking url.getPath() being not null.
                
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> -Use case and why it fails-
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Aki Yoshida (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aki Yoshida resolved CXF-3884.
------------------------------

    Resolution: Fixed

url-decoding now applied for file path determination.

Thanks to Oliver for analyzing this issue.
                
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>            Assignee: Aki Yoshida
>             Fix For: 2.3.8, 2.4.4
>
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> _Use case and why it fails_
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (CXF-3884) [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly

Posted by "Freeman Fang (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Fang closed CXF-3884.
-----------------------------

    
> [JAXB] DynamicClientFactory#setupClasspath does not handle URL encoded file names correctly
> -------------------------------------------------------------------------------------------
>
>                 Key: CXF-3884
>                 URL: https://issues.apache.org/jira/browse/CXF-3884
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.3
>            Reporter: Olivier Costet
>            Assignee: Aki Yoshida
>             Fix For: 2.3.8, 2.4.4
>
>
> Hi,
> I believe there is a bug in
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#setupClasspath(StringBuilder, ClassLoader).
> That method goes through the classloader hierarchy trying to find
> classpath components. Among others, it checks the resource URLs returned
> by java.net.URLClassLoader#getUrls(), trying to find a corresponding JAR
> file.
> However, its handling of the URLs is incorrect and fails if it
> encounters a URL-encoded file path, for instance:
>  file:/C:/Program%20Files/Crapware/etc.
> The code is:
> URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
> file = new File(uri.getPath()); 
> This doesn't work. The java.net.URI c'tor used here *escapes* characters
> as necessary.
> Correct code would use:
> URI uri = new URI(url.toString());
> file = new File(uri.getPath());
> or
> URI uri = new URI(url.getProtocol(), null,
> URLDecoder.decode( url.getPath(), "UTF-8" ), null, null);
> file = new File(uri.getPath()); 
> -.-
> _Use case and why it fails_
> My code, running in an application container, creates a client using the
> DynamicClientFactory from some WSDL. 
> That WSDL declares some (simple) types.
> Those types are bound (via JAXB) to Java types that are part of my
> application.
> Code generation works fine, creating Adapters from the basic types to
> the bound types.
> But #setupClasspath() fails to find my application's JARs, because
> they're loaded by the application classloader, a URLClassLoader, and are
> on a path containing a space.
> Consequently, the generated files cannot be compiled, because the bound
> Java types cannot be resolved.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira