PDA

View Full Version : ConcurrentModificationException + RefreshableValueHolder



afida
Nov 10th, 2004, 05:41 AM
I have a Wizard with a one WizardPage and a Form. It use to work fine but i have updated to new spring lib and I am starting to get some really strange errors.

I have a RefreshableValueHolder that updates ComboBox items on show(). As the model is changing so I need to update combobox model.

Following is the exception that Iam getting on wizard.execute().



03:39:51,448 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Setting newly selected item on value holder to Accounting

03:39:51,448 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Notifying combo box view selected value changed; new value is 'Accounting'

03:39:51,498 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Firing contents change event; selected item may have changed

03:39:51,498 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Returning selected item Accounting

03:39:51,498 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Returning selected item Accounting

03:39:51,498 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Returning selected item Accounting

03:39:51,498 DEBUG [org.springframework.richclient.list.DynamicComboB oxListModel] Fired contents change event!

03:39:51,508 ERROR [org.springframework.richclient.application.config .ApplicationAdvisor]

java.util.ConcurrentModificationException

at java.util.LinkedHashMap$LinkedHashIterator.nextEnt ry(LinkedHashMap.java:354)

at java.util.LinkedHashMap$KeyIterator.next(LinkedHas hMap.java:365)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:64)

at org.springframework.binding.value.support.Buffered ValueModel.onWrappedValueChanged(BufferedValueMode l.java:82)

at org.springframework.binding.value.support.Buffered ValueModel$WrappedModelValueChangeHandler.valueCha nged(BufferedValueModel.java:70)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:64)

at org.springframework.binding.value.support.Property Adapter$DomainObjectChangeHandler.valueChanged(Pro pertyAdapter.java:70)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:64)

at org.springframework.binding.value.support.ValueHol der.setValue(ValueHolder.java:52)

at org.springframework.binding.form.support.AbstractF ormModel.setFormObject(AbstractFormModel.java:69)

at org.springframework.richclient.forms.CompoundForm. setFormObject(CompoundForm.java:55)

at com.vaau.rbacx.client.ui.view.businessunitsview.Ne wNewBusinessUnitWizard.execute(NewNewBusinessUnitW izard.java:53)

at com.vaau.rbacx.client.ui.view.businessunitsview.Ne wNewBusinessUnitWizard.execute(NewNewBusinessUnitW izard.java:61)

at org.springframework.richclient.command.TargetableA ctionCommand.doExecuteCommand(TargetableActionComm and.java:97)

at org.springframework.richclient.command.ActionComma nd.execute(ActionCommand.java:188)

at org.springframework.richclient.command.ActionComma nd$1.actionPerformed(ActionCommand.java:123)

at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:257)

at javax.swing.AbstractButton.doClick(AbstractButton. java:289)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Bas icMenuItemUI.java:1113)

at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputH andler.mouseReleased(BasicMenuItemUI.java:943)

at java.awt.Component.processMouseEvent(Component.jav a:5134)

at java.awt.Component.processEvent(Component.java:493 1)

at java.awt.Container.processEvent(Container.java:156 6)

at java.awt.Component.dispatchEventImpl(Component.jav a:3639)

at java.awt.Container.dispatchEventImpl(Container.jav a:1623)

at java.awt.Component.dispatchEvent(Component.java:34 80)

at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3095)

at java.awt.Container.dispatchEventImpl(Container.jav a:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1590 )

at java.awt.Component.dispatchEvent(Component.java:34 80)

at java.awt.EventQueue.dispatchEvent(EventQueue.java: 450)

at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:99)



Here is my wizard.execute()


public void execute() {
if (wizardDialog == null) {
wizardDialog = new WizardDialog(this);
wizardDialog.setResetMessagePaneOnDisplay(true);
wizardForm = new CompoundForm();
}
wizardForm.setFormObject(new BusinessUnit());
wizardDialog.showDialog();
}


Here is my form.createControl()



protected JComponent createFormControl() {
FormLayout layout = new FormLayout("left:pref, 5dlu, pref:grow");
JGoodiesBeanFormBuilder formBuilder = new JGoodiesBeanFormBuilder(getFormModel(), layout);
businessUnitNameField =(JTextField) formBuilder.add("businessUnitName")[1];
refreshableValueHolder = new RefreshableValueHolder(new Block() {
public Object call(Object object) {
return getFlattenedBusinessUnits();
}
}, true);

parentBusinessUnitComboBox =
getFormModel().createBoundComboBox("parentBusinessUnit", refreshableValueHolder, "businessUnitName");

formBuilder.getWrappedFormBuilder().add(PARENT_BUS INESS_UNIT_LABEL_ID, parentBusinessUnitComboBox);
return formBuilder.getForm();
}

I am going nuts over this, please any help will be really appreciated.

Amad

pdbruycker
Nov 10th, 2004, 06:23 AM
modify your getFlattenedBusinessUnits method so it returns a copy of your internal collection. (if it's a list do the following: return new ArrayList(internalList);

afida
Nov 10th, 2004, 11:20 AM
modify your getFlattenedBusinessUnits method so it returns a copy of your internal collection. (if it's a list do the following: return new ArrayList(internalList);

I have looked at my code and thats what I do already. Any ideas
Amad

Keith Donald
Nov 10th, 2004, 11:38 AM
Amad,

Are you spawning any other threads at all? Did you just synchronize today? Perhaps send me the code off-line I can take a look and add some tests.

afida
Nov 10th, 2004, 01:08 PM
Are you spawning any other threads at all?
No

Did you just synchronize today?
I had synchronized a week ago.

snpe
Nov 10th, 2004, 06:44 PM
Amad,
try with TableFormBuilder except Jgoodies

regards

afida
Nov 10th, 2004, 07:22 PM
snpe


try with TableFormBuilder except Jgoodies

Is there a TableBeanFormBuilder?

Amad[/quote]

snpe
Nov 10th, 2004, 07:44 PM
There is TableFormBuilder

see user documentation form support (it is on wiki)

It is new, JGoodiesBeanFormBuilder is deprecated

for table support exists BeanTableModel

regards

Keith Donald
Nov 10th, 2004, 07:44 PM
It's TableFormBuilder. See the latest petclinic snapshot for example usage.

Hey Amad, also try synchronzing with the latest snapshot to see if its still a problem.

Keith

afida
Nov 11th, 2004, 12:06 AM
I have got the latest build and now using TableFormBuilder. Problem still persists, I have commented out some code and here is the line the causing the problem,


getFormModel().createBoundComboBox(selectionFormPr operty, selectableItemsHolder, renderedItemProperty);

Because if I take it out, exception goes away! Any clues :idea:

afida
Nov 11th, 2004, 01:42 AM
I have further simplified my createControl() and now it looks like following, note there is no reference to any global domain objects...


protected JComponent createFormControl() {
TableFormBuilder formBuilder = new TableFormBuilder(getFormModel());
businessUnitNameField = formBuilder.add("businessUnitName")[1];
BusinessUnit bu = new BusinessUnit();
bu.setBusinessUnitName("Vaau");
ArrayList list = new ArrayList();
list.add(bu);

ValueHolder valueHolder = new ValueHolder(list);
parentBusinessUnitComboBox = getFormModel().createBoundComboBox("parentBusinessUnit", valueHolder, "businessUnitName");
formBuilder.row();
formBuilder.add(PARENT_BUSINESS_UNIT_LABEL_ID, parentBusinessUnitComboBox);
return formBuilder.getForm();
}

I took out the refreshableValueHolder but I get the same exception. As long as I use the createBoundComboBox() method that takes ValueHolder i get the exception. with Just wanted to update the exception I am getting since i have change the form builder and using latest spring snapshot.


java.util.ConcurrentModificationException

at java.util.LinkedHashMap$LinkedHashIterator.nextEnt ry(LinkedHashMap.java:354)

at java.util.LinkedHashMap$KeyIterator.next(LinkedHas hMap.java:365)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:64)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:90)

at org.springframework.binding.value.support.Buffered ValueModel.setValue(BufferedValueModel.java:145)

at org.springframework.binding.value.support.Buffered ValueModel.revert(BufferedValueModel.java:198)

at org.springframework.binding.value.support.Buffered ValueModel$CommitTriggerHandler.valueChanged(Buffe redValueModel.java:110)

at org.springframework.binding.value.support.Abstract ValueModel.fireValueChanged(AbstractValueModel.jav a:64)

at org.springframework.binding.value.support.CommitTr igger.setValue(CommitTrigger.java:75)

at org.springframework.binding.form.support.DefaultFo rmModel.revert(DefaultFormModel.java:224)

at org.springframework.richclient.forms.SwingFormMode l.revert(SwingFormModel.java:318)

at org.springframework.richclient.form.builder.TableF ormBuilder.getForm(TableFormBuilder.java:102)

at com.vaau.rbacx.client.ui.view.businessunitsview.Ne wNewBusinessUnitWizard$NewBusinessUnitForm.createF ormControl(NewNewBusinessUnitWizard.java:128)

at org.springframework.richclient.forms.AbstractForm. createControl(AbstractForm.java:222)

at org.springframework.richclient.factory.AbstractCon trolFactory.getControl(AbstractControlFactory.java :48)

at org.springframework.richclient.wizard.FormBackedWi zardPage.createControl(FormBackedWizardPage.java:7 1)

at org.springframework.richclient.dialog.AbstractDial ogPage$1.createControl(AbstractDialogPage.java:50)

at org.springframework.richclient.factory.AbstractCon trolFactory.getControl(AbstractControlFactory.java :48)

at org.springframework.richclient.dialog.AbstractDial ogPage.getControl(AbstractDialogPage.java:201)

at org.springframework.richclient.wizard.WizardDialog .createPageControls(WizardDialog.java:128)

at org.springframework.richclient.wizard.WizardDialog .createTitledDialogContentPane(WizardDialog.java:8 4)

at org.springframework.richclient.dialog.TitledApplic ationDialog.createDialogContentPane(TitledApplicat ionDialog.java:119)

at org.springframework.richclient.dialog.TitledApplic ationDialog.addDialogComponents(TitledApplicationD ialog.java:108)

at org.springframework.richclient.dialog.ApplicationD ialog.createDialog(ApplicationDialog.java:285)

at org.springframework.richclient.dialog.ApplicationD ialog.showDialog(ApplicationDialog.java:254)

at com.vaau.rbacx.client.ui.view.businessunitsview.Ne wNewBusinessUnitWizard.execute(NewNewBusinessUnitW izard.java:56)

at com.vaau.rbacx.client.ui.view.businessunitsview.Ne wNewBusinessUnitWizard.execute(NewNewBusinessUnitW izard.java:63)

at org.springframework.richclient.command.TargetableA ctionCommand.doExecuteCommand(TargetableActionComm and.java:97)

at org.springframework.richclient.command.ActionComma nd.execute(ActionCommand.java:188)

at org.springframework.richclient.command.ActionComma nd$1.actionPerformed(ActionCommand.java:123)

at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:257)

at javax.swing.AbstractButton.doClick(AbstractButton. java:289)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Bas icMenuItemUI.java:1113)

at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputH andler.mouseReleased(BasicMenuItemUI.java:943)

at java.awt.Component.processMouseEvent(Component.jav a:5134)

at java.awt.Component.processEvent(Component.java:493 1)

at java.awt.Container.processEvent(Container.java:156 6)

at java.awt.Component.dispatchEventImpl(Component.jav a:3639)

at java.awt.Container.dispatchEventImpl(Container.jav a:1623)

at java.awt.Component.dispatchEvent(Component.java:34 80)

at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3095)

at java.awt.Container.dispatchEventImpl(Container.jav a:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1590 )

at java.awt.Component.dispatchEvent(Component.java:34 80)

at java.awt.EventQueue.dispatchEvent(EventQueue.java: 450)

at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:99)

Keith Donald
Nov 11th, 2004, 01:50 AM
I am seeing the same problem in my application, now, after upgrading. I will take care of it ASAP.