我創建使用IllegalStateException異常:無法覆蓋因番石榴map.put
new MapMaker().softValues().maximumSize(cacheSize).makeMap();
這似乎做工精細的地圖,但是,我有時會收到下面的異常訪問後在服務器上部署後馬上將新元素添加到地圖中:
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)
...
可能是什麼原因?
---更新時間:
JBoss的版本是5
設置在Throwable.initCause斷點透露ClassNotFoundException
與消息: Invalid use of destroyed classloader for com.google.common.collect.Iterators, UCL destroyed at:
並與堆棧跟蹤
ClassNotFoundException(Throwable).initCause(Throwable):320
UnifiedClassLoader3(RepositoryClassLoader).findClass(String):628
...
UnifiedClassLoader3(ClassLoader).loadClass(String):248
CustomConcurrentHashMap$2.iterator():828
CustomConcurrentHashMap$2(AbstractCollection<E>).remove(Object):241
CustomConcurrentHashMap$Segment.enqueueCleanup(...):2738
CustomConcurrentHashMap$Segment.unsetValue(...):2662
CustomConcurrentHashMap<K, V>.reclaimValue(...)
CustomConcurrentHashMap$SoftValueReference<K, V>.finalizeReferent():1637
...
Method.invoke:574
Finalizer.claenUp:154
Finalizer.run:127
從堆棧跟蹤,看起來好像地圖中的某個對象已經在finalizeReferent
的類別com.google.common.collect.Iterators
中無法加載。
這似乎更像是一個JBoss問題而不是番石榴問題。由於Guava代碼的緣故,您正好碰到它。 –