[jdom-interest] ADDING A CHILD....

Mark Hortman mark.hortman at jcafeinc.com
Thu Dec 12 07:32:01 PST 2002


Your problem is that you have asked for all children on the first line,
then you get a list of iterators, the you start modifying the list.
The iterator checks to see if the list has been modified and blows chunks
because, it
is like getting a map, then building a road right through the middle of the
what the map covers,
then trying to use the map to navigate around in area, and you say "Hey!
This road isn't on the Map!"

Try adding the newatcher on before you get the iterator, and it should work
fine.

-----Original Message-----
From: Antonello Dell'Armi [mailto:A.Dellarmi at ELIS.ORG]
Sent: Thursday, December 12, 2002 9:07 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] ADDING A CHILD....


i have the element instance that have inside the elements watcher.I would
like to add a new element watcher with text watcherID.
But the following snipped of code doesn't work correctly. 

List watchers = instance.getChildren("watcher");

Iterator iter = watchers.iterator();

Element newatcher = new Element("watcher");

newatcher.setText(watcherID);

watchers.add(newatcher);
while(iter.hasNext()){

	Element watcher = (Element) iter.next();
	String w = watcher.getText();
	System.out.println("watcher= " + w);
}

I get the error below. Any help?   BRGS antonello

Exception in thread "main" java.util.ConcurrentModificationException
        at
java.util.LinkedList$ListItr.checkForComodification(LinkedList.java
48)
        at java.util.LinkedList$ListItr.next(LinkedList.java:484)
        at UPMDataManagerImpl.addWatcher(UPMDataManagerImpl.java:475)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list