Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:27:33+00:00 2026-05-13T16:27:33+00:00

I think I found more bugs in my web application. Normally, I do not

  • 0

I think I found more bugs in my web application. Normally, I do not worry about concurrency issues, but when you get a ConcurrentModificationException, you begin to rethink your design.

I am using JBoss Seam in conjuction with Hibernate and EHCache on Jetty. Right now, it is a single application server with multiple cores.

I briefly looked over my code and found a few places that haven’t thrown an exception yet, but I am fairly sure they can.

The first servlet filter I have basically checks if there are messages to notify the user of an event that occurred in the background (from a job, or another user). The filter simply adds messages to the page in a modal popup. The messages are stored on the session context, so it is possible another request could pull the same messages off the session context.

Right now, it works fine, but I am not hitting a page with many concurrent requests. I am thinking that I might need to write some JMeter tests to ensure this doesn’t happen.

The second servlet filter logs all incoming requests along with the session. This permits me to know where the client is coming from, what browser they’re running, etc. The problem I am seeing more recently is on image gallery pages (where there are many requests at about the same time), I end up getting a concurrent modification exception because I’m adding a request to the session.

The session contains a list of requests, this list appears to be being hit by multiple threads.

@Entity
public class HttpSession 
{
  protected List<HttpRequest> httpRequests;

  @Fetch(FetchMode.SUBSELECT)
  @OneToMany(mappedBy = "httpSession")
  public List<HttpRequest> getHttpRequests()
  {return(httpRequests);}

  ...
}

@Entity
public class HttpRequest
{
  protected HttpSession httpSession;

  @ManyToOne(optional = false)
  @JoinColumn(nullable = false)
  public HttpSession getHttpSession()
  {return(httpSession);}

  ...
}

In that second servlet filter, I am doing something of the sort:

httpSession.getHttpRequests().add(httpRequest);
session.saveOrUpdate(httpSession);

The part that errors out is when I do some comparison to see what changed from request to request:

for(HttpRequest httpRequest:httpSession.getHttpRequests())

That line there blows up with a concurrent modification exception.

Things to walk away with:
1. Will JMeter tests be useful here?
2. What books do you recommend for writing web applications that scale under concurrent load?
3. I tried placing synchronized around where I think I need it, ie on the method that loops through the requests, but it still fails. What else might I need to do?

I added some comments:

I had thought about making the logging of the http requests a background task. I can easily spawn a background task to save that information. I am trying to remember why I didn’t evaluate that too much. I think there is some information that I would like to have access to on the spot.

If I made it asynchronous, that would speed up the throughput quite a bit – well I’d have to use JMeter to measure those differences.

I would still have to deal with the concurrency issue there.

Thanks,

Walter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:27:33+00:00Added an answer on May 13, 2026 at 4:27 pm

    A ConcurrentModificationException occurrs when any collection is modified while iterating over it. You can do it in a single thread, e.g.:

    for( Object o : someList ) {
      someList.add( new Object() );
    }
    

    Wrap your list with Collections.synchronizedList or return an unmodifiable copy of the list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've gone through just about every property I can think of, but haven't found
I found a similar post about this but still not sure. As I am
I found this page describing the Muenchian method, but I think I'm applying it
The PHP documentation can be found here , but I think it's rather lacking.
Often, I found OutOfMemoryException on IBM Websphere Application Server. I think this exception occur
I started to think about tracking changes in complex object graph in disconnected application.
I think this is specific to IE 6.0 but... In JavaScript I add a
I don't know how authoritative this is but I found this: http://www.sqlite.org/cvstrac/wiki?p=PerformanceConsiderations and it
I've found a solution, see my own answer below. Does anyone have a more
I've been going deeper into C++ recently and my bugs seem to get complex.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.