#29 Exception on first page hit

open
nobody
None
5
2007-05-03
2007-05-03
Wolfgang
No

Under some cirumstances the following exception
is thrown when accessing the first JSF-Page after
Application start.
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at de.mindmatters.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:211)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
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:213)
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.valves.RequestFilterValve.process(RequestFilterValve.java:275)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:80)
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:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
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()V(Unknown Source)

Discussion

  • Wolfgang

    Wolfgang - 2007-05-03

    Logged In: YES
    user_id=629874
    Originator: YES

    It looks like that when accessing listener-List by iterator somone other is
    adding or removing elements.
    Changing the lines 168-179 in LifecycleImpl.java from
    synchronized (listeners) {
    PhaseEvent event = new PhaseEvent(context, phaseId, this);
    for (Iterator i = listeners.iterator(); i.hasNext();) {
    PhaseListener listener = (PhaseListener) i.next();
    if (phaseId.equals(listener.getPhaseId())
    || PhaseId.ANY_PHASE.equals(listener.getPhaseId())) {
    listener.afterPhase(event);
    }
    }
    }

    to
    synchronized (listeners) {
    PhaseEvent event = new PhaseEvent(context, phaseId, this);
    for(int i=0;i<listeners.size();i++){
    PhaseListener listener = (PhaseListener) listeners.get(i);
    if (phaseId.equals(listener.getPhaseId())
    || PhaseId.ANY_PHASE.equals(listener.getPhaseId())) {
    listener.afterPhase(event);
    }
    }
    }

    Not using the iterator helps me and the error is gone.
    Maybe someone has an idea why are elements added or removed while
    iterating in the executePhase-Method.

     
  • Wolfgang

    Wolfgang - 2007-05-04

    Logged In: YES
    user_id=629874
    Originator: YES

    After some more research I know why the exception is thrown.
    At the beginning, before first page access, there is a Listener from Ajax4JSF in the List of Listeners. This is an Init-Listener which means after first execution of this Listener it removes himself from the Listener list. Unforutnately this Listener is
    at second position and after it there are some more Listeners which had to be called.
    So before all listeners called in the for-loop the listener removes himself and the iterator is inconsistent.

     
  • Marco Beelen

    Marco Beelen - 2007-05-29

    Logged In: YES
    user_id=1229950
    Originator: NO

    We are having the same problem sometimes.

    This problem appairs to be fixed in version 1.7 of the file: /jsf-spring/src/de/mindmatters/faces/lifecycle/LifecycleImpl.java.

    Unfortunately this was fixed after the 4.0.2. release was build, so we are waiting for the 4.0.3 release.

     

Log in to post a comment.