[kaffe] Problem with Strings/Xml Parsing while trying to run an embedded Jetty

Ito Kazumitsu kaz at maczuka.gcd.org
Tue Oct 18 23:00:15 PDT 2005


From: Rafael Teixeira <monoman at gmail.com>
Date: Tue, 18 Oct 2005 10:45:06 -0200

> > > > > Also when Jetty is trying to read the configuration xmls, DTD aren't
> > > > > being correctly loaded in the sax validator:
> > > > >
> > > > > INFO: Version Jetty/5.1.x
> > > > >
> > > > > org.xml.sax.SAXParseException: Element type 'web-app' was not declared
> Again the same configuration files embedded in the jar run fine in
> Sun's VM and Jetty gets started and runs my web-app...
> 
> The web-app not being accepted is the one in my WEB-INF/web.xml that
> uses another DTD, that indeed should accept 'web-app'
> 
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

By disabling xerces, I could reproduce the same error:
"org.xml.sax.SAXParseException: Element type 'web-app' was not declared".

> I've put some diagnostic printlns inside the
> gnu.xml.pipeline.ValidationConsumer.startElement method that is
> raising the error, and surely it looks like the DTDs isn't being
> loaded as it list of valid elements is empty at start (it adds the
> offending item to the list so that it can continue to validate without
> reissuing the same error for similar itens, so the list grows during
> the execution).

I am afraid gnu.xml package is not mature enough as a validating
XML parser.  Much work will be needed to make it stable.

> So again looks like some other problem (I guess again with string
> manipulation) may be precluding the DTDs from being parsed/loaded and
> so the other errors appear.

Switching the SAX parser to xerces solves the problem. So I think
the problem exists in gnu.xml package.

Suggested workaround for now is either

  (1) Use xerces.  Xerces comes with Jetty and it can be activated
      by setting the system property javax.xml.parsers.SAXParserFactory
      to org.apache.xerces.jaxp.SAXParserFactoryImpl

  or

  (2) Do not try to validate the configuration XML files. Jetty will not
      validate the XML files if the system property
      org.mortbay.xml.XmlParser.NotValidating is set to true.




More information about the kaffe mailing list