Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5414

classpath: paths containing spaces are ignored

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6.2
    • None
    • jaxws
    • tested on Windows, but should appear on linux too

    Description

      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?

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            tguerin Thierry Guérin

            Dates

              Created:
              Updated:

              Slack

                Issue deployment