1 Reply Latest reply on Aug 28, 2002 6:58 AM by Manan

    concurrent modification problem: java.util.ConcurrentModific

    Manan Newbie

      1. Taskmanager is the servlet class I am using. No code written related to "threads" is being written. I encountered this exception "java.util.ConcurrentModificationException"

      This exception may be thrown by methods that have detected concurrent modification of a backing object when such modification is not permissible. For some reasons, two thread are getting started.


      I am encountering the following error:

      StandardWrapperValve[taskmanager]: Servlet.service()
      for servlet taskmanager threw exception java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.next(HashMap.java:736)
      at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:166)
      at TaskManager.doPost(TaskManager.java:139)
      at TaskManager.doGet(TaskManager.java:54)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:243)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
      a:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:190)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:566)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
      .java:246)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
      a:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
      2343)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:180)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:566)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
      rValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:564)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
      468)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
      a:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:174)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
      .java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
      a:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

      at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso
      r.java:1012)
      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
      va:1107)
      at java.lang.Thread.run(Thread.java:484)


      For some reasons, it seems that a new thread is getting started.

      Do I need to specify in some file that no new thread should start-off. How can I get rid of this error?

      Any pointers?

        • 1. Re: concurrent modification problem: java.util.ConcurrentMod
          Manan Newbie

          Relevant Code present for session tracking is:

          String enumName = "";
          while(sessionNames.hasMoreElements())
          {
          enumName = (String)sessionNames.nextElement();
          session.removeAttribute(enumName);
          }

          When I uncomment the above code and run my application, it works fine.

          Since I need to setattribute also, therefore ,I dont want to use session.invalidate().

          Right now ,what it seems different threads get created if I dont comment the code.

          How can I run the application without commenting above code on jboss-3.0.0_tomcat-4.0.3?

          any pointers?