I am trying to create svg file of a jgo image in server without showing a window. It uses some batik libraries also. I tried the example code that I got from JGO 5.1 release. It works when run in windows 2000 command prompt (using java.exe). But fails in 3 tier client server mode:
The server throws the following error:
Uncaught error fetching image:<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.ja va:99)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java: 108)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImag eSource.java:248)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Here is the code that I am using:
public class SVGGoView extends JGoView {
public SVGGoView() {
}
public void generateSVG(OutputStream outputStream) {
// Get a DOMImplementation
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document
Document document = domImpl.createDocument(null, "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask JGoView to render into the SVG Graphics2D implementation
JGoDocument doc = this.getDocument();
Point pt = this.getDocumentTopLeft();
Dimension dim = this.getDocumentSize();
Rectangle rect = new Rectangle(pt.x, pt.y, dim.width, dim.height);
paintView(svgGenerator, rect);
// Finally, stream out SVG to the standard output using UTF-8
// character to byte encoding
boolean useCSS = true; // we want to use CSS style attribute
try {
Writer out = new OutputStreamWriter(outputStream, "UTF-8");
svgGenerator.stream(out, useCSS);
}
catch (Throwable t) {
t.printStackTrace();
}
}