Getting random exception on saveAsJpeg

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Dustin Breese

Getting random exception on saveAsJpeg

Post by Dustin Breese » Fri Feb 21, 2003 9:09 am

I am getting the following periodically when generating charts. I am using JDBC datasets and various charts (Scatter, Line, Time series, etc).

What could cause this?

Exception in thread "main" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:440)
at java.util.AbstractList$Itr.next(AbstractList.java:417)
at com.jrefinery.chart.plot.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown Source)
at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at ChartCreator.main(ChartCreator.java:150)

The line of code for the ChartCreator is:
150: ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

Any ideas would be greatly helpful!

Thanks,
Dustin
dbreese@qwest.com

David Gilbert

Re: Getting random exception on saveAsJpeg

Post by David Gilbert » Fri Feb 21, 2003 1:38 pm

Is it possible that you are updating the dataset at the same time as the chart is being drawn? At present, there is no thread synchronisation between the datasets and the chart...it is something that is near the top of the list for fixing...

Regards,

Dave Gilbert

Dustin Breese

Re: Getting random exception on saveAsJpeg

Post by Dustin Breese » Mon Feb 24, 2003 4:06 pm

David,

Thanks for the reply.

That may be the case. Since it is an applet and I am saving the chart in the main method after the window has been rendered, there are then 2 threads, right? One for my code and one for the rendering/management of the window. However, none of my code modifies the dataset after the window is rendered -- it just uses a JDBCXXXDataset.

The "workaround" I found right after posting the above message was to put a Thread.sleep(2000) before it saves to a PNG/JPEG file. I bet the "real" fix would be to move the save logic into the same method where I render the window?

-Dustin

Locked