3 Replies Latest reply on Mar 10, 2005 4:33 PM by Scott Stark

    Spaces in Paths - %20 Weirdness

    Dave Lindquist Newbie

      I've just tried implementing a web application (servlet-based) on JBoss and have the following problem:

      Whenever the application tries to use File objects to hold paths that have spaces in them, it appears that the spaces *magically* become "%20". (This causes accessing the files to fail.)

      (JBoss itself is *not* installed in a path with spaces.)

      This application works perfectly under Tomcat, JRun, and Weblogic, so I'm not sure why JBoss causes this.

      Secondly, because the File object is supplied by *Sun*, not by JBoss, I have *NO* idea how it could screw this up?

      I found some (old) references to adding:

      <mbean code="org.jboss.util.FileURLPatch" name="DefaultDomain:service=FileURLPatch">
       <attribute name="Enabled">true</attribute>

      to jboss.jcml (now jboss-service.xml?), but that fails with "ClassDefNotFound".

      Does anyone have any ideas? Or explanations? Hell, I'll take wild speculation at this point...[/url]

        • 1. Re: Spaces in Paths - %20 Weirdness
          Dave Lindquist Newbie

          Further information...

          The root cause of this appears to be the fact that JBoss registers itself as an URLConnection provider, and it's FileURLConnection object is broken (replaces spaces with %20).

          This occurs when trying to do a parse on an XML document giving the parser a File object.

          Here's a stack trace to show how it works:

          java.io.FileNotFoundException: D:\path\with%20spaces\to\file.xml
           at org.jboss.net.protocol.file.FileURLConnection.connect(FileURLConnection.java:71)
           at org.jboss.net.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:80)
           at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
           at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
           at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
           at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
           at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)

          Is there any workaround to fix this damn thing?

          • 2. Re: Spaces in Paths - %20 Weirdness
            Doug Beachy Newbie

            Yes, this is nasty JBoss bug that is killing us in deployment. I'm amazed that this bug is still there all the way through version 4.0.1. I am working on submitting a proper bug report, but in the meantime I have created a patched lib/jboss-common.jar with the following fix to FileURLConnection.java:


            public FileURLConnection(final URL url)
             throws MalformedURLException, IOException
             // D. Beachy: fix to handle URI-encoded paths with spaces
             String decodedPath = URLDecoder.decode(url.getPath().replace('/', File.separatorChar).replace('|', ':'), "UTF-8");
             file = new File(decodedPath);
             doOutput = false;


            Then I compiled it and updated the original jboss-common.jar with the class file. Presto -- JBoss now correctly handles real file URLs. I still can't believe this bug hasn't been fixed long before now...

            - Doug