Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6506304
Votes 36
Synopsis java.net.MalformedURLException: unknown protocol: c
Category jaxp:other
Reported Against
Release Fixed 1.4, 6u13-rev(b06) (Bug ID:2174009) , 6u14(b05) (Bug ID:2176330)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 19-DEC-2006
Description
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. customer .xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:650)
	at com.sun.org. customer .xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
	at com.sun.org. customer .xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org. customer .xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org. customer .xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
	at com.sun.org. customer .xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1132)
	at com.sun.org. customer .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.
Posted Date : 2006-12-19 20:27:37.0
Work Around
N/A
Evaluation
Reassign the issue to me. 

This is a regression from jdk1.5 as the suggested workaround and several user inputs indicated.
Posted Date : 2008-09-03 06:53:29.0

There are many interests in this issue. I'm rasing the priority and asking for an integration.
Posted Date : 2009-03-02 19:31:28.0

Fixed in jaxp 1.4 on java.net. Will request for integration into jdk6 update release.
Posted Date : 2009-03-05 18:43:10.0
Comments
  
  Include a link with my name & email   

Submitted On 22-FEB-2007
jglick
How is this a bug? The listed URI is simply invalid. Use

reader.parse(new File("C:\\space error\\x.xml").toURI().toString());


Submitted On 09-MAR-2007
jon_ralph
This is a bug since this code works on all prior versions before 1.6


Submitted On 16-MAR-2007
aaubry
Try to parse the file directly or the input stream related to the file. It should works.

The following code is working withe JDK 1.5

...
SAXParserFactory factory = SAXParserFactory.newInstance();
		
	    try { 
	        SAXParser parser = factory.newSAXParser();
	    	parser.parse(file, handler);
         ....


Though, parsing the same stream from a String object is not working and raises the same exception you have.

Alexandre


Submitted On 27-MAR-2007
java80
I have faced the same problem.Had some code that use to work fine on 1.5 and today when i tried it with 1.6 it failed,and google bought me here.....
Mick


Submitted On 12-APR-2007
It seems that the bug is also in Java version "C:\Program Files\Java\jre1.5.0_01\bin\java.exe"
on the platform Windows(R) Server 2003, Enterprise Edition
OS Version:                5.2.3790 Service Pack 1 Build 3790
because the same bat file works fine on Windows XP.

my.bat:
set xercesDIR=c:/work/
"C:\Program Files\Java\jre1.5.0_01\bin\java.exe"   -classpath "%xercesDIR%xjparse-1.0.jar;%xercesDIR%resolver.jar" com.nwalsh.parsers.xjparse -d 5 -s -c "%xercesDIR%myxmlcatalog.xml" "%xercesDIR%myfiletovalidate.xml"


Work Around is pass on command line options url instead of path, example:
"file:///%xercesDIR%myfiletovalidate.xml"


Submitted On 09-SEP-2008
Event though you use the suggested workaround:
reader.parse(new File("C:\\space error\\x.xml").toURI().toString());
you will face another problem:
if the referenced DTD is local you get a FileNotFoundException
i.e: <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">


Submitted On 09-OCT-2008
David.F
I had a line with same exception :
		
          document = builder.parse(translationFileName);
		
I succeed to get rid of error with 'new File(...)':
		
          document = builder.parse(new File(translationFileName));


Submitted On 27-FEB-2009
chamness
Sill an issue in:
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

At a minimum, there should be a more specific error message.


Submitted On 26-MAR-2009
wwwjames
Which update release of JDK 6 has the fix ? 
We just tried to verify the fix with 1.6.0_13-b03 and it is still broken.



PLEASE NOTE: JDK6 is formerly known as Project Mustang