java.util.ConcurrentModificationException

Hibernate JIRA | Kenneth Flynn | 7 years ago
  1. 0

    When I create two EntityManagerFactories in two different threads, I get the stacktrace below. It looks like I'm determining the persistence provider implementations twice at the same time; the static set in the Persistence class is not thread safe; in particular findAllProviders() fails if it is called concurrently. In this case, the use of the persistence api in the two different threads is completely unrelated--they are using different persistence units, different dbs, etc. This seems like a use case that should be supported? [java] java.util.ConcurrentModificationException [java] at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) [java] at java.util.HashMap$KeyIterator.next(HashMap.java:828) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51) [java] at com.darkcorner.minotaur.sa.redline.RedlineDatabaseControl.ensureRunning(RedlineDatabaseControl.java:101) [java] at com.darkcorner.minotaur.sa.redline.RedlineService.restartService(RedlineService.java:316) [java] at com.darkcorner.harmonice.ServiceHandler.callRestart(ServiceHandler.java:241) [java] at com.darkcorner.harmonice.ServiceHandler.access$000(ServiceHandler.java:56) [java] at com.darkcorner.harmonice.ServiceHandler$RestartTask.run(ServiceHandler.java:63) [java] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [java] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [java] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [java] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [java] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) [java] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [java] at java.lang.Thread.run(Thread.java:619)

    Hibernate JIRA | 7 years ago | Kenneth Flynn
    java.util.ConcurrentModificationException
  2. 0

    When I create two EntityManagerFactories in two different threads, I get the stacktrace below. It looks like I'm determining the persistence provider implementations twice at the same time; the static set in the Persistence class is not thread safe; in particular findAllProviders() fails if it is called concurrently. In this case, the use of the persistence api in the two different threads is completely unrelated--they are using different persistence units, different dbs, etc. This seems like a use case that should be supported? [java] java.util.ConcurrentModificationException [java] at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) [java] at java.util.HashMap$KeyIterator.next(HashMap.java:828) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51) [java] at com.darkcorner.minotaur.sa.redline.RedlineDatabaseControl.ensureRunning(RedlineDatabaseControl.java:101) [java] at com.darkcorner.minotaur.sa.redline.RedlineService.restartService(RedlineService.java:316) [java] at com.darkcorner.harmonice.ServiceHandler.callRestart(ServiceHandler.java:241) [java] at com.darkcorner.harmonice.ServiceHandler.access$000(ServiceHandler.java:56) [java] at com.darkcorner.harmonice.ServiceHandler$RestartTask.run(ServiceHandler.java:63) [java] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [java] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [java] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [java] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [java] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) [java] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [java] at java.lang.Thread.run(Thread.java:619)

    Hibernate JIRA | 7 years ago | Kenneth Flynn
    java.util.ConcurrentModificationException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    ConcurrentModification exception in timer thread

    GitHub | 4 years ago | tfmorris
    java.util.ConcurrentModificationException

  1. iridic 2 times, last 2 weeks ago
  2. franky li 1 times, last 1 month ago
  3. bpbhat77 2 times, last 3 months ago
  4. bpbhat77 1 times, last 5 months ago
  5. asvid 2 times, last 6 months ago
1 more registered users
9 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.ConcurrentModificationException

    No message provided

    at java.util.HashMap$HashIterator.nextEntry()
  2. Java RT
    HashMap$KeyIterator.next
    1. java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
    2. java.util.HashMap$KeyIterator.next(HashMap.java:828)
    2 frames
  3. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
    1 frame
  4. com.darkcorner.minotaur
    RedlineService.restartService
    1. com.darkcorner.minotaur.sa.redline.RedlineDatabaseControl.ensureRunning(RedlineDatabaseControl.java:101)
    2. com.darkcorner.minotaur.sa.redline.RedlineService.restartService(RedlineService.java:316)
    2 frames
  5. com.darkcorner.harmonice
    ServiceHandler$RestartTask.run
    1. com.darkcorner.harmonice.ServiceHandler.callRestart(ServiceHandler.java:241)
    2. com.darkcorner.harmonice.ServiceHandler.access$000(ServiceHandler.java:56)
    3. com.darkcorner.harmonice.ServiceHandler$RestartTask.run(ServiceHandler.java:63)
    3 frames
  6. Java RT
    Thread.run
    1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    2. java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    3. java.util.concurrent.FutureTask.run(FutureTask.java:138)
    4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    5. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
    6. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    7. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    8. java.lang.Thread.run(Thread.java:619)
    8 frames