Source xml File = new Stream Source(new File("web.xml")); Schema Factory schema Factory = Schema Factory Instance(XMLConstants.
Sun's JDK 6 uses SAX parser with a Stream Source. There is no change in XML as well as Java parsing code. If input stream is not closed properly then this exception may happen. This code has been working for ages (7 years), only after recent server crash, we faced this problem on one of the servers. Does it work if you create the Input Source from a File Input Stream instead of a File Reader?If you are generating XML files programatically, you may want to look at the XMLBeans library.Using a command line tool, XMLBeans will automatically generate and package up a set of Java objects based on an XSD.