Skip to main content

I got "java.util.ConcurrentModificationException" when refresh my web page.

No replies
nuboat
Offline
Joined: 2013-11-17
Points: 0

This error has random error. You can reproduce by repeatedly press refresh.

My environment:
I run on CentOS with Java 7u45 and Glassfish 3.1.2.2.
Start glassfish on Cluster mode and created node1 for instance1 and node2 for instance2 (SSH).

My Code use JSF CDI with Conversation scope

@Named
@ConversationScoped
public class HomeView implements Serializable {

private static final Logger LOG = LoggerFactory.getLogger(HomeView.class);

private int count;
private String message;
private String name;

@Inject
private HelloFacade facade;

@Inject
private Conversation conversation;

@PostConstruct
public void initial() {
count = 0;
name = "World";
message = "Hello World!";
conversation.begin();
LOG.info("Instance: {} ConversationId: {} Begin", System.getProperty("com.sun.aas.instanceName"), conversation.getId());
}

public void hello() throws NamingException {
count++;
message = facade.getMessage(name);
LOG.info("Instance: {} ConversationId: {} Hello", System.getProperty("com.sun.aas.instanceName"), conversation.getId());
}

....
}

Below is full Exception
SEVERE: 17:30:33,667 : thread-169 : - : java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:926)
at java.util.HashMap$EntryIterator.next(HashMap.java:966)
at java.util.HashMap$EntryIterator.next(HashMap.java:964)
at java.util.HashMap.writeObject(HashMap.java:1131)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:2067)
at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.catalina.session.StoreBase.writeSession(StoreBase.java:269)
at org.glassfish.web.ha.session.management.HAStoreBase.getByteArray(HAStoreBase.java:229)
at org.glassfish.web.ha.session.management.ReplicationStore.doValveSave(ReplicationStore.java:152)
at org.glassfish.web.ha.session.management.ReplicationWebEventPersistentManager.doValveSave(ReplicationWebEventPersistentManager.java:159)
at org.glassfish.web.ha.session.management.HASessionStoreValve.doPostInvoke(HASessionStoreValve.java:181)
at org.glassfish.web.ha.session.management.HASessionStoreValve.postInvoke(HASessionStoreValve.java:142)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:670)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ajp.AjpProcessorTask.invokeAdapter(AjpProcessorTask.java:135)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:744)

SEVERE: 17:30:33,668 : thread-169 : - : at java.util.HashMap$HashIterator.nextEntry(HashMap.java:926)
SEVERE: 17:30:33,668 : thread-169 : - : at java.util.HashMap$EntryIterator.next(HashMap.java:966)
SEVERE: 17:30:33,668 : thread-169 : - : at java.util.HashMap$EntryIterator.next(HashMap.java:964)
SEVERE: 17:30:33,669 : thread-169 : - : at java.util.HashMap.writeObject(HashMap.java:1131)
SEVERE: 17:30:33,669 : thread-169 : - : at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
SEVERE: 17:30:33,670 : thread-169 : - : at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
SEVERE: 17:30:33,670 : thread-169 : - : at java.lang.reflect.Method.invoke(Method.java:606)
SEVERE: 17:30:33,670 : thread-169 : - : at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
SEVERE: 17:30:33,671 : thread-169 : - : at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
SEVERE: 17:30:33,671 : thread-169 : - : at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
SEVERE: 17:30:33,671 : thread-169 : - : at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
SEVERE: 17:30:33,672 : thread-169 : - : at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
SEVERE: 17:30:33,672 : thread-169 : - : at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:2067)
SEVERE: 17:30:33,672 : thread-169 : - : at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
SEVERE: 17:30:33,673 : thread-169 : - : at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
SEVERE: 17:30:33,673 : thread-169 : - : at java.lang.reflect.Method.invoke(Method.java:606)
SEVERE: 17:30:33,674 : thread-169 : - : at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
SEVERE: 17:30:33,674 : thread-169 : - : at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
SEVERE: 17:30:33,674 : thread-169 : - : at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
SEVERE: 17:30:33,675 : thread-169 : - : at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
SEVERE: 17:30:33,675 : thread-169 : - : at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
SEVERE: 17:30:33,675 : thread-169 : - : at org.apache.catalina.session.StoreBase.writeSession(StoreBase.java:269)
SEVERE: 17:30:33,676 : thread-169 : - : at org.glassfish.web.ha.session.management.HAStoreBase.getByteArray(HAStoreBase.java:229)
SEVERE: 17:30:33,676 : thread-169 : - : at org.glassfish.web.ha.session.management.ReplicationStore.doValveSave(ReplicationStore.java:152)
SEVERE: 17:30:33,676 : thread-169 : - : at org.glassfish.web.ha.session.management.ReplicationWebEventPersistentManager.doValveSave(ReplicationWebEventPersistentManager.java:159)
SEVERE: 17:30:33,677 : thread-169 : - : at org.glassfish.web.ha.session.management.HASessionStoreValve.doPostInvoke(HASessionStoreValve.java:181)
SEVERE: 17:30:33,677 : thread-169 : - : at org.glassfish.web.ha.session.management.HASessionStoreValve.postInvoke(HASessionStoreValve.java:142)
SEVERE: 17:30:33,677 : thread-169 : - : at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:670)
SEVERE: 17:30:33,678 : thread-169 : - : at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
SEVERE: 17:30:33,678 : thread-169 : - : at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
SEVERE: 17:30:33,679 : thread-169 : - : at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
SEVERE: 17:30:33,679 : thread-169 : - : at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
SEVERE: 17:30:33,679 : thread-169 : - : at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
SEVERE: 17:30:33,680 : thread-169 : - : at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
SEVERE: 17:30:33,680 : thread-169 : - : at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
SEVERE: 17:30:33,680 : thread-169 : - : at com.sun.grizzly.http.ajp.AjpProcessorTask.invokeAdapter(AjpProcessorTask.java:135)
SEVERE: 17:30:33,681 : thread-169 : - : at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
SEVERE: 17:30:33,681 : thread-169 : - : at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
SEVERE: 17:30:33,681 : thread-169 : - : at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
SEVERE: 17:30:33,682 : thread-169 : - : at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
SEVERE: 17:30:33,682 : thread-169 : - : at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
SEVERE: 17:30:33,682 : thread-169 : - : at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
SEVERE: 17:30:33,683 : thread-169 : - : at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
SEVERE: 17:30:33,683 : thread-169 : - : at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
SEVERE: 17:30:33,683 : thread-169 : - : at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
SEVERE: 17:30:33,684 : thread-169 : - : at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
SEVERE: 17:30:33,684 : thread-169 : - : at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
SEVERE: 17:30:33,684 : thread-169 : - : at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
SEVERE: 17:30:33,685 : thread-169 : - : at java.lang.Thread.run(Thread.java:744)