I develop my application with FOP (Apache's formatter) on Oracle's JDeveloper 9i - there everything works OK.
But when I deploy application (through war file) to
Tomcat 4.0.3, problems begin.
By this simple code I load XML file and change its encoding:
Document document;
XMLDocument xdoc;
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 from 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 (with different beahavior) - Document.class 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 instead from xmlparserv2.jar.
I am still rather new to this. Do I need to have set Classpath or something else installed, even if the application is run via web-browser ? (Now I have Tomcat and browser on one PC)
Does somebody see the solution to this ? Thanks.