Caused by: java.lang.IllegalArgumentException: Item with specified ID does


I have use grid in my panel with delete column and one add button in panel which add the new row in grid.
when I delete the row from grid then it works, but when I add a new item then some times it gives following Exception.

I have refresh the grid while deleteing the item.
public void refresh() {


Caused by: java.lang.IllegalArgumentException: Item with specified ID does not exist in data source
at com.vaadin.ui.Grid.scrollTo([69:com.vaadin.server:7.6.5]

at com.vaadin.ui.Grid.scrollTo([69:com.vaadin.server:7.6.5]

at com.knorrbremse.icom.leader.ui.components.grid.RestoreSelectionListener.selectByBean(
at com.knorrbremse.icom.leader.ui.components.grid.RestoreSelectionListener.detach(
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)[:1.8.0_40]

at java.lang.reflect.Method.invoke(Unknown Source)[:1.8.0_40]

at com.vaadin.event.ListenerMethod.receiveEvent([69:com.vaadin.server:7.6.5]

... 57 more


Is any pointer to solve this problem?

It looks like you are having some other code that is using that Grid too in event handling. One of your events seems perform scrollTo() certain item. Now my best guess is that at the same time event is run, you are deleting the items from the container. Hence scrollTo() gives exception since the item is not in the container anymore.

Thanks Tatu Lund,

kindly tell me how can I handle this exception?

on delete action I have to remove the item from container and refresh it.

Another thing is it does not through exception each occors randomly.