3 Replies Latest reply on Dec 18, 2009 7:52 AM by samvimes

    ConcurrentModification Exception when calling actionlistener

      Hi Everyone,
      in production environment sometimes a concurrent modification exception occurs if a specific acrion listener is called (see below) which in turn modifies an array list.

       

      The page code looks like this...

       

      <a4j:keepAlive beanName="userPage" ajaxOnly="true"/>
              <a4j:queue name="userPageQueue" size="10" ignoreDupResponses="true"/>
      
              <a4j:form id="searchForm" eventsQueue="userPageQueue">
                ...
               <a4j:commandButton id="btnDeleteButton" value="User löschen" styleClass="std_button" reRender="p_lblUserCount, p_dsrUsers, p_tblUsers,                     btnDeleteButton, editForm:userData"
                      disabled="#{userPage.deleteButtonDisabled}" actionListener="#{userPage.deleteUsers}" />
                </a4j:form>
              <a4j:form id="editForm" eventsQueue="userPageQueue">
                ...
           </a4j:form>
      

       

      I use a request scoped bean with a4j:keepAlive. As suggested in http://community.jboss.org/thread/16652?start=15&tstart=0 I used a queue to synchronize the method calls on the page. Since I still get a concurrent modification do I need to explicitly synchronize the method or use a session bean instead? What is the suggested way to solve this problem?

       

      I use Facelets 1.1.4, JSF 1.2_13 on WebSphere 6.1

       

      Best regards

      Carsten

        • 1. Re: ConcurrentModification Exception when calling actionlistener
          ilya_shaikovsky
          post your bean code also please
          • 2. Re: ConcurrentModification Exception when calling actionlistener

            This is the called actionListener. Exception occurs while looping through the selected users with the iterator.

             

                 public void deleteUsers(ActionEvent e) {
                    releaseLock();
                    resetDetails();
                    userErrorMessages.clear();
            
                    Mandator mandator = sessionContext.getMandator();
                    UserTableEntry user;
                    String msg;
                        
                    for (Iterator<UserTableEntry> currentUserList = users.iterator(); currentUserList
                            .hasNext();) {
                        user = currentUserList.next();
            
                        if (user.isSelected()) {
                            try {
                                msg = userService.deleteUser(user, mandator);
            
                                if (msg.equals(""))
                                    currentUserList.remove();
                                else
                                    userErrorMessages
                                            .add(buildUserErrorMessage(user,
                                                    msg));
                            } catch (DataAccessException dae) {
                                logger.error(dae.getMessage(), dae);
                                ...
                            }
                        }
                    }
            
                    if (userErrorMessages.isEmpty()) {
                        statusPopupRendered = true;
                    } else {
                        userResultPopupRendered = true;
                    }
                }
            
            • 3. Re: ConcurrentModification Exception when calling actionlistener
              As a workaround I will explicitly synchronize the method call but are there no further suggestions?