java – IllegalStateException:无法覆盖Guava 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: 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. 解决方法
您的问题似乎与MapMaker或Guava无关.
您只看到处理另一个异常时发生的异常(不幸的是). Throwable.initCause()在调用时抛出异常,同时已经为当前Throwable指定了一个原因(通过方法或构造函数`). RepositoryClassLoader.findClass()方法似乎正在处理一些它期望没有原因的异常,但事实上它已经有一个原因集,它触发了这个异常. 不幸的是,你在这里看到的异常隐藏了实际的异常(这对于解决问题可能更为重要). 尝试在Throwable.initCause()第320行或RepositoryClassLoader.findClass()(第624行)放置一个breakpoit,并重现问题(希望)在IDE的局部变量视图中看到“真实”异常. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |