-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: java.util.ConcurrentModificationException
PostPosted: Wed Jun 22, 2005 8:21 am 
Newbie

Joined: Tue Jun 21, 2005 2:59 am
Posts: 2
Hi,

I am using Hibernate 3.0.5. The code below is used to detach the style from logged users' group.

Group group = (Group)sess.get(Group.class, loggedUser.getGroup().getId());

Set<Style> groupStyles = group.getGroupStyles();

if(groupStyles != null || groupStyles.size() > 0)
{
Iterator iter = groupStyles.iterator();

while(iter.hasNext())
{
Style st = (Style)iter.next();

//if style selected for deletion matches with the group style, remove the entry
if(style.getName().equalsIgnoreCase(st.getName()))
{
groupStyles.remove(style);
}
}
}

Full stack trace of the exception that occurred is::

java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$KeyIterator.next(HashMap.java:823)
at org.hibernate.collection.AbstractPersistentCollection$IteratorProxy.next(AbstractPersistentCollection.java:366)
at com.rmsi.omadmin.Persister.deleteStyle(Persister.java:825)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:62)
at javax.faces.component.UICommand.broadcast(UICommand.java:106)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:110)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:184)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:112)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

Any hints will be highly appreciated.

Regards

Rashmi


Top
 Profile  
 
 Post subject: Re: java.util.ConcurrentModificationException
PostPosted: Wed Jun 22, 2005 10:59 am 
Newbie

Joined: Sat Jun 11, 2005 5:27 am
Posts: 11
rashmi wrote:
Hi,

while(iter.hasNext())
{
Style st = (Style)iter.next();

//if style selected for deletion matches with the group style, remove the entry
if(style.getName().equalsIgnoreCase(st.getName()))
{
groupStyles.remove(style);
}
}
}


Rashmi


I've had a few of these lately. The problem is deleting stuff from the collection without telling the active Iterator about it. Use

Code:
iter.remove();


Rather than
Code:
grourStyles.remoce(style);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 1:27 am 
Newbie

Joined: Tue Jun 21, 2005 2:59 am
Posts: 2
Thanx a lot

Its now working as desired.

Thanx again


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.