We have a chart that refreshes every two minutes. The data is loaded to the chart via a servlet. The chart datasource is an input stream and the data is in an array format. On initial load the chart and all labels work fine. When the chart refreshes we get a series of the error message below repeated. I tried to removeAllLabels when I refresh and readd them but it did not seem to help. How do I fix this error?
Exception in thread "AWT-EventQueue-2" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at com.klg.jclass.chart.JCDefaultChartLabelManager.paintConnectors(Unknown Source)
at com.klg.jclass.chart.JCChart.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at com.klg.jclass.chart.JCChart.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. It is usually caused when modifying a Collection while another thread is iterating on it.
Make sure all chart code (including creation) is run within the Swing Event Dispatch Thread and this error shouldn't occur. You can also use SwingUtilities.invokeLater() or SwingUtilities.invokeAndWait() to defer processing to the AWT thread.
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center