This same output code works fine when the chart contains data.
Code:
Code: Select all
JFree Chartchart = ChartFactory.createTimeSeriesChart(_jobName,
"Time",
"",
new TimeSeriesCollection(new TimeSeries("")),
false, false, false);
chart.getXYPlot().setNoDataMessage("No Data Match.");
// Output the PNG chart to the outputstream in the given size
try {
ChartUtilities.writeChartAsPNG(this.getOutputStream(), chart, 1024, 768);
this.getOutputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
Code: Select all
javax.imageio.IIOException: I/O error writing PNG file!
[jetty] 13:58:10.917 [qtp0-2] ERROR STDERR - at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1152)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at javax.imageio.ImageWriter.write(ImageWriter.java:598)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at javax.imageio.ImageIO.write(ImageIO.java:1479)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at javax.imageio.ImageIO.write(ImageIO.java:1565)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at org.jfree.chart.encoders.SunPNGEncoderAdapter.encode(SunPNGEncoderAdapter.java:127)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at org.jfree.chart.encoders.EncoderUtil.writeBufferedImage(EncoderUtil.java:134)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:185)
[jetty] 13:58:10.918 [qtp0-2] ERROR STDERR - at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:136)
Basically the correct looking empty chart is put to the outputstream, but after that an IOException is thrown, which is causing issues on my server. When the chart has data, it is written to the outputstream and no exception is thrown.
Any ideas on what to look at? I'd expect an empty chart (where the noDataMessage is used) to be put on the outputstream with no exception just like a filled chart.
Thanks,
Dan