Hello,
I am developing a
servlet running under
tomcat.
All was working fine (tomcat serves
JSP form to Mozilla Firefox, form data inserted back into mySQL, all processes running on local machine) until I restarted tomcat with the webapp rebuilt with a batik SVG object. Now, the servlet runs, but the form never loads, and this message appears in catalina.out:
"Gtk-WARNING **: cannot open display:"
The JSP that fails attempts to instantiate a javabean, which now (this build) attempts to instantiate the batik SVG object.
Just before running into this error, I received the following error, for the same build, in (log4j's) tomcat.log:
java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument
... this error was encountered as the JSP instantiated the bean, and was fixed by providing the following links in $CATALINA_HOME/common/lib/
xml-apis-ext.jar -> /opt/batik/batik-1.7/lib/xml-apis-ext.jar
batik-svg-dom.jar -> /opt/batik/batik-1.7/lib/batik-svg-dom.jar
batik-util.jar -> /opt/batik/batik-1.7/lib/batik-util.jar
batik-awt-util.jar -> /opt/batik/batik-1.7/lib/batik-awt-util.jar
batik-svggen.jar -> /opt/batik/batik-1.7/lib/batik-svggen.jar
batik-dom.jar -> /opt/batik/batik-1.7/lib/batik-dom.jar
Here's the relevant code in the SVG object:
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.svg.SVGDocument;
private SVGGraphics2D svggen;
private DOMImplementation dom;
private SVGDocument
doc;
... in the constructor:
dom = SVGDOMImplementation.getDOMImplementation();
doc = (SVGDocument) dom.createDocument(null, "svg", null);
svggen = new SVGGraphics2D(doc);
I successfully run this same object in a standalone version (
java swing) of this webapp on this PC. The SVG enabled Firefox browser (adobesvg-3.01-linux-i386) successfully loads the SVG images this application produces.
Regarding possible Xserver issues, i'm logged in as me, and start/stop tomcat by way of 'sudo /sbin/service'. The links to the batik jars, and the jars themselves, are owned by user 'tomcat'. I have other tomcat webapps on this box, and they run fine ... this must be some sort of unhappiness about SVG, n'est-ce pas?
Thanks!
Paul
ps:
- Linux 2.6.17-1.2174_FC5 (Fedora Core 5)
- tomcat5-5.5.15-1jpp_6fc
- jdk1.5.0_08
- Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.6)
Gecko/20060808
Fedora/1.5.0.6-2.fc5
Firefox/1.5.0.6
pango-text