Thierry Guérin created AXIS2-5414:
-------------------------------------

             Summary: classpath: paths containing spaces are ignored
                 Key: AXIS2-5414
                 URL: https://issues.apache.org/jira/browse/AXIS2-5414
             Project: Axis2
          Issue Type: Bug
          Components: jaxws
    Affects Versions: 1.6.2
         Environment: tested on Windows, but should appear on linux too
            Reporter: Thierry Guérin


When the classpath contains paths with spaces, the classes contained in this 
path are ignored. An easy way to reproduce this is to have your App Server 
installed in a path that contains spaces. When calling a webService, the 
following exception is raised: 
DEBUG org.apache.axis2.transport.http.AxisServlet [OnDemandLogger.java:85] 
org.apache.axis2.AxisFault: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element 
(uri:"http://my/namespace";, local:"myMethod"). Expected elements are (none)]
The only way to find out why this happening is to look at the logs in debug 
mode and spot the "DEBUG org.apache.axis2.jaxws.message.databinding.JAXBUtils 
[JAXBUtils.java:1051] getClassesFromJarFile failed to get Classes", which is 
not really explanatory on the source of the problem.

The bug lies with the class ClassFinderImpl which calls url.toURI() with an URL 
that contains spaces. the URI class is pretty strict about RFC 2396 and throws 
an exception if spaces are not escaped.
Here's a patch & testcase that solves the problem.
I first thought about only escaping space and still using url.toURI, but then I 
figured that if the space wasn't escaped, chances were that other characters 
would also not be, and that the url was surely built using "file:/" + 
file.getPath(), so instead url.toURI is used, and when this fails, 
url.getPath() is used.

Note on the test: as I wanted to make sure that the class could be loaded from 
a url path both correctly escaped and not escaped, the test class is dumped in 
a temporary jar and getClassesFromJarFile is called. Maybe there's a simpler 
way to do this.

The priority is major because I feel that the symptoms are quite obscure and 
require debugging to figure out what's wrong; feel free to set it to minor as 
the workaround is quite simple.

final note on the patch: while writing the test, I found out that the jars read 
by getClassesFromJarFile where not closed, so I fixed it. the patch includes 
the fix, but should I open a separate bug?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to