title: IllegalStateException: Can't overwrite cause in Guava map.put
body: <p>I create a map using </p>
  
  <pre><code>new MapMaker().softValues().maximumSize(cacheSize).makeMap();
  </code></pre>
  
  <p>This seemed to work fine, however, I sometimes get the following exception after accessing right after deploying on the server and putting new elements into the map:</p>
  
  <pre><code>java.lang.IllegalStateException: Can't overwrite cause
    at java.lang.Throwable.initCause(Throwable.java:320)
    at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:624)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:474)
    at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at com.google.common.collect.CustomConcurrentHashMap$2.iterator(CustomConcurrentHashMap.java:828)
    at java.util.AbstractCollection.remove(AbstractCollection.java:241)
    at com.google.common.collect.CustomConcurrentHashMap$Segment.removeFromChain(CustomConcurrentHashMap.java:2599)
    at com.google.common.collect.CustomConcurrentHashMap$Segment.processPendingCleanup(CustomConcurrentHashMap.java:2772)
    at com.google.common.collect.CustomConcurrentHashMap$Segment.runLockedCleanup(CustomConcurrentHashMap.java:2860)
    at com.google.common.collect.CustomConcurrentHashMap$Segment.preWriteCleanup(CustomConcurrentHashMap.java:2806)
    at com.google.common.collect.CustomConcurrentHashMap$Segment.put(CustomConcurrentHashMap.java:2374)
    at com.google.common.collect.CustomConcurrentHashMap.put(CustomConcurrentHashMap.java:3346)
    at my.app.cache.CacheImplGoogleGuava.put(CacheImplGoogleGuava.java:36)
  ...
  </code></pre>
  
  <p>What could be the reason?</p>
  
  <p>--- Updated:</p>
  
  <p>JBoss version is 5. </p>
  
  <p>Setting a breakpoint in Throwable.initCause revealed <code>ClassNotFoundException</code> with message:
  <code>Invalid use of destroyed classloader for com.google.common.collect.Iterators, UCL destroyed at:</code>
  and with Stacktrace </p>
  
  <pre><code>ClassNotFoundException(Throwable).initCause(Throwable):320
  UnifiedClassLoader3(RepositoryClassLoader).findClass(String):628
  ...
  UnifiedClassLoader3(ClassLoader).loadClass(String):248
  CustomConcurrentHashMap$2.iterator():828
  CustomConcurrentHashMap$2(AbstractCollection&lt;E&gt;).remove(Object):241
  CustomConcurrentHashMap$Segment.enqueueCleanup(...):2738
  CustomConcurrentHashMap$Segment.unsetValue(...):2662
  CustomConcurrentHashMap&lt;K, V&gt;.reclaimValue(...)
  CustomConcurrentHashMap$SoftValueReference&lt;K, V&gt;.finalizeReferent():1637
  ...
  Method.invoke:574
  Finalizer.claenUp:154
  Finalizer.run:127
  </code></pre>
  
  <p>From the stacktrace, it seems as if an object in the map was finalized where in <code>finalizeReferent</code> the class <code>com.google.common.collect.Iterators</code> cannot be loaded.</p>