when i am trying to parse an xml, i am getting following exception :-
java.net.UnknownHostException: hibernate.sourceforge.net
at java.net.AbstractPlainS
The parser is trying to download the DTD from hibernate.sourceforge.net
in order to validate the parsed XML.
However, the DNS client on the machine can't resolve that host name for some reason (it resolves fine to 82.98.86.175
on my machine).
To avoid this problem, you have to tell the DocumentBuilderFactory
to ignore the DTD:
File hbmFile = new File(hbmFileName);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(hbmFile);
See Make DocumentBuilder.parse ignore DTD references.