You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Ji...@orcz.cz on 2002/10/22 10:07:10 UTC

Tomcat , problem with libraries order

I develop my application with FOP on Oracle's JDeveloper 9i - there
everything works OK.

But when I deploy application (through war file) to Tomcat 4.0.3, some
problems begin.

By this simple code I load XML file and change its encoding

Document document;
    XMLDocument xdoc;
    FileOutputStream f2;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating(false);
    DocumentBuilder builder = dbf.newDocumentBuilder();
    document = builder.parse(new File("report.xml"));
    xdoc = (XMLDocument) document;                           // ERROR ON
TOMCAT
    String se = xdoc.getEncoding();
    xdoc.setEncoding("WINDOWS-1250");


The marked line generates error "ClassCastException".

Both Document and XMLDocument are form the library XMLPARSERV2.JAR which is
loaded before every library FOP 0.20.3 uses  (avalon-framework-4.0.jar,
batik.jar, logkit-1.0.jar , xalan-2.0.0.jar, xerces.jar)
But the class with same name (but with different beahavior)  - Document is
also stored in  batik.jar, xalan-2.0.0.jar  and xerces.jar.

I think that Tomcat somewhat mixes the libraries order and takes
Document.class from one of the FOP libraries.


Does somebody see the solution to this ? Thanks.





Re: Tomcat , problem with libraries order

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jiri_Nejedly@orcz.cz wrote:
> I develop my application with FOP on Oracle's JDeveloper 9i - there
> everything works OK.
> 
> But when I deploy application (through war file) to Tomcat 4.0.3, some
> problems begin.
> 
> By this simple code I load XML file and change its encoding
> 
> Document document;
>     XMLDocument xdoc;
>     FileOutputStream f2;
>     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>     dbf.setValidating(false);
>     DocumentBuilder builder = dbf.newDocumentBuilder();
>     document = builder.parse(new File("report.xml"));
>     xdoc = (XMLDocument) document;                           // ERROR ON
> TOMCAT
>     String se = xdoc.getEncoding();
>     xdoc.setEncoding("WINDOWS-1250");
> 
> 
> The marked line generates error "ClassCastException".
That's not surprising. Document is an *interface*, the actual implementation
is choosen by the parser and usually read from a configuration. While
Oracle seems to have anmed its implementation XMLDocument, Xerces uses some
other class. Either *replace* the Xerces jars in tomcat's lib directory
with the Oracle jar (not recommended, the Oracle parser is fast but slightly
buggy), or configure tomcat so that it takes the parser configuration from the
webapp's jars, look at the tomcat documentation. You'll need at .east 4.0.4
for the latter.

J.Pietschmann