camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Route HANGS processing XML with external DOCTYPE declaration
Date Wed, 18 Sep 2013 14:06:00 GMT
Hi Dale

Sounds like a good idea to have a way of configuring this easily in Camel.
Feel free to log a JIRA and attach your code.

Though wonder also how we can make it easier to set any other custom
features as well.



On Wed, Sep 18, 2013 at 3:54 PM, Dale King <dalewking@gmail.com> wrote:
> I've used xpath routes previously and had no problem. I tried doing a split
> with xpath on an XHTML document however and the route just hangs. It
> doesn't throw an exception or simply fail to find a match for the XPath, it
> just hangs.
>
> After 4-5 hours of debugging the issue, I have discovered it is because the
> XHTML contains an external DTD declaration (a DOCTYPE) as it should. When
> converting the XML content to a DOM it tries to load the external DTD which
> never completes, causing the route to hang.
>
> The solution I have found is to add the following class and declare it as a
> bean in the Spring configuration and Spring will autowire it into the
> XmlConverter, but I would be interested in knowing anything better to avoid
> the lockup:
>
> @SuppressWarnings("restriction")
> public class NoExternalDtdDocumentBuilderFactory extends
> DocumentBuilderFactoryImpl
>  {
>     public NoExternalDtdDocumentBuilderFactory() throws
> ParserConfigurationException
>     {
>         setValidating(false);
>         setNamespaceAware(true);
>         setFeature("http://xml.org/sax/features/namespaces", false);
>         setFeature("http://xml.org/sax/features/validation", false);
>         setFeature("
> http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
>         setFeature("
> http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
>     }
> }
>
>
> --
> Dale King



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message