java.util.ConcurrentModificationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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)
    via by Kenneth Flynn,
  • 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)
    via by Kenneth Flynn,
    • java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$KeyIterator.next(HashMap.java:828) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51) at com.darkcorner.minotaur.sa.redline.RedlineDatabaseControl.ensureRunning(RedlineDatabaseControl.java:101) at com.darkcorner.minotaur.sa.redline.RedlineService.restartService(RedlineService.java:316) at com.darkcorner.harmonice.ServiceHandler.callRestart(ServiceHandler.java:241) at com.darkcorner.harmonice.ServiceHandler.access$000(ServiceHandler.java:56) at com.darkcorner.harmonice.ServiceHandler$RestartTask.run(ServiceHandler.java:63) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    iridic
    2 times, last one,
    franky li
    1 times, last one,
    bpbhat77
    2 times, last one,
    21 more bugmates