tags:

views:

25

answers:

1

If I try to create a new xml document in a java applet by this code:

http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance()

DocumentBuilderFactory.newInstance();

I will get this error:

Java Plug-in 1.6.0_19
Using JRE version 1.6.0_19-b04 Java HotSpot(TM) Client VM

javax.xml.parsers.FactoryConfigurationError: Provider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; not found
        at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)

I do not care about DTD's.

  1. Why is it looking for it?
  2. How am I supposed to create a xml document in java applets?
  3. How can I make it work?

The enclosing html document looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html>
<head>
<title>Loading...</title>
</head>

Can some comment this thread?

The problem was with the entity resolver, which points to the w3c.org web site. The access to the reference DTDs on this site has been restricted for application use. The solution was to implement my own entity resolver.

Related:

  1. http://forums.sun.com/thread.jspa?threadID=515055
  2. http://stackoverflow.com/questions/1016286/org-apache-xerces-jaxp-saxparserfactoryimpl-not-found-when-importing-gears-api-in
  3. http://java.itags.org/java-desktop/4839/
+1  A: 

If all you are doing is calling DocumentBuilderFactory.newInstance(); then this should not cause an error. The posts you link to are not relevant.

javax.xml.parsers.FactoryConfigurationError: Provider <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; not found

This suggests some weird configuration error/bug. The provider should (I think) be the factory class name of the JAXP implementation. Check that you aren't doing something strange like setting the javax.xml.parsers.DocumentBuilderFactory system property or have an invalid META-INF/services/javax.xml.parsers.DocumentBuilderFactory file on your Applet classpath.

McDowell