[jdom-interest] ConcurrentModificationException

Garrett Zork zork263 at lycos.com
Wed Mar 27 22:40:38 PST 2002

I've gotten a ConcurrentModificationException in my code.  Can
someone share the main reasons for getting this Exception?  

I eliminated the error by grabbing my List from Jaxen rather
than JDOM, though, this is obviously not my preferred solution.

I'm running JDOM b8 (and Jaxen- beta 8)

I'm not using threads, and didn't "remove" anything from
the List - either through the iterator or outside of the iterator.
I would certainly like to know the JDOM programming constructs 
to avoid.
Snippet of offending code:  (sorry for the linewrap)

//List templateList=sectionElement.getChildren("template");  
//This JDOM List fails

List templateList=UtilXML.getXpathResults(sectionElement,"template");
//This (convenience method) Jaxen List succeeds

Iterator templateIter=templateList.iterator();

int pageCount=0;
while (templateIter.hasNext()) {       //This is line 78: where the exception occurs
    PageMap myPageMap= new PageMap(section);

    for (int i=0;(i<sectionColumnCount && templateIter.hasNext());i++) {
	for (int j=0;(j<sectionRowCount && templateIter.hasNext());j++) {
	    Element templateElement=(Element) templateIter.next();
            Template myTemplate= new Template(templateElement);
            myPageMap.addTemplate(myTemplate, i, j);

here's the stacktrace:

	at org.jdom.ContentList$FilterListIterator.checkConcurrentModification(ContentList.java:1206)
	at org.jdom.ContentList$FilterListIterator.hasNext(ContentList.java:928)
	at ig.CatalogBuilder.buildSection(CatalogBuilder.java:78)
	at ig.CatalogBuilder.<init>(CatalogBuilder.java:65)
	at ig.TestCatalogBuilder.main(TestCatalogBuilder.java:24)
Exception in thread "main" 

See Dave Matthews Band live or win a signed guitar

More information about the jdom-interest mailing list