Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6506304

java.net.MalformedURLException: unknown protocol: c

XMLWordPrintable

    • 1.4
    • x86
    • windows_xp

        FULL PRODUCT VERSION :
        c:\>java -version
        java version "1.6.0"
        Java(TM) SE Runtime Environment (build 1.6.0-b105)
        Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


        ADDITIONAL OS VERSION INFORMATION :
        Windows XP SP2

        A DESCRIPTION OF THE PROBLEM :
        When trying to parse an XML file, a java.net.MalformedURLException is thrown if there is a space anywhere within the full path file name.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a folder on the hard drive named "space error" ( note the space in the name ) and put a valid xml file in the folder. run the program.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Exception
        ACTUAL -
        Exception

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        unknown protocol: c
        java.net.MalformedURLException: unknown protocol: c
        at java.net.URL.<init>(URL.java:574)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:650)
        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1132)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:533)
        at test.main(test.java:16)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.intellij.rt.execution.application.AppMain.main(Unknown Source)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import org.xml.sax.XMLReader;
        import javax.xml.parsers.*;
        public class test
        {
            public static void main(String[] arfgs)
            {
                try
                {
                    SAXParserFactory factory = SAXParserFactory.newInstance();
                    factory.setNamespaceAware(true);
                    SAXParser jaxpParser = factory.newSAXParser();
                    XMLReader reader = jaxpParser.getXMLReader();
                    reader.parse("C:/space error/x.xml");
                    System.exit(0);
                }
                catch(Exception e)
                {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                    System.exit(16);
                }
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        use prior version or include a J2EE jar file in your class path.

              joehw Joe Wang
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: