集群 Wildfly 抛出 java.lang.IllegalAccessError
Posted
技术标签:
【中文标题】集群 Wildfly 抛出 java.lang.IllegalAccessError【英文标题】:Clustered Wildfly throws java.lang.IllegalAccessError 【发布时间】:2016-03-22 04:06:42 【问题描述】:我在 Wildfly 托管域上运行应用程序,该域由 2 个虚拟机组成,每个虚拟机上有 3 个服务器。
console.log 中出现异常:
14:04:10,254 WARN [org.jboss.weld.Servlet] (default task-51) WELD-000717: Unable to deactivate context org.jboss.weld.context.http.HttpRequestContextImpl@2ec2ea52 when destroying request HttpServletRequestImpl [ GET /orpon/ ]
14:04:10,254 WARN [org.jboss.weld.Servlet] (default task-51) WELD-000717: Unable to deactivate context org.jboss.weld.context.http.HttpSessionContextImpl@f171e22 when destroying request HttpServletRequestImpl [ GET /orpon/ ]
14:04:10,254 ERROR [io.undertow.request] (default task-51) Undertow request failed HttpServerExchange GET /orpon/: java.lang.IllegalAccessError: Can not set final int field io.undertow.util.HttpString.hashCode to (int)-1978065285
at io.undertow.util.HttpString.readObject(HttpString.java:340)
at sun.reflect.GeneratedMethodAccessor167.invoke(Unknown Source) [:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_66]
at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:307)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1644)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365) [rt.jar:1.8.0_66]
at java.util.HashMap.readObject(HashMap.java:1394) [rt.jar:1.8.0_66]
at sun.reflect.GeneratedMethodAccessor157.invoke(Unknown Source) [:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_66]
at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:307)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365) [rt.jar:1.8.0_66]
at java.util.HashMap.readObject(HashMap.java:1396) [rt.jar:1.8.0_66]
at sun.reflect.GeneratedMethodAccessor157.invoke(Unknown Source) [:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_66]
at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:307)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
at org.wildfly.clustering.marshalling.SimpleMarshalledValue.get(SimpleMarshalledValue.java:101)
at org.wildfly.clustering.marshalling.SimpleMarshalledValue.get(SimpleMarshalledValue.java:45)
at org.wildfly.clustering.marshalling.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:45)
at org.wildfly.clustering.marshalling.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:32)
at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionFactory.findValue(CoarseSessionFactory.java:127)
at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionFactory.findValue(CoarseSessionFactory.java:56)
at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:232)
at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:115)
at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:723)
at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:753)
at io.undertow.servlet.spec.ServletContextImpl.updateSessionAccessTime(ServletContextImpl.java:757)
at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:548)
at io.undertow.servlet.spec.HttpServletResponseImpl.doErrorDispatch(HttpServletResponseImpl.java:162)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:317)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_66]
我尝试使用 openjdk-1.8 和 Oracle jdk-1.8 在 Wildfly 8.2.1.Final 和 9.0.2 Final 上运行应用程序,结果相同。应用程序部署并运行没有错误,我通过负载均衡器(循环)成功登录并在服务器上工作。
In undertow sources at github 类 hashCode
的字段 io.undertow.util.HttpString
声明为 final transient int
。为什么readObject
方法试图以非常奇怪的方式更改该字段的值?
我在互联网上搜索过,但没有发现有关此错误或类似错误的信息,也不知道如何处理。
我的申请中属于这个例外的地方可能在哪里?
更新: Undertow server 的这个补丁可以帮助我避免问题:
From 7083c4145878f954bbde14f1f6acbb31414c88d9 Mon Sep 17 00:00:00 2001
From: fedor patlin <patlin.f@sovzond.center>
Date: Fri, 18 Dec 2015 15:55:32 +0500
Subject: [PATCH] Set field hashCodeField accessible
---
core/src/main/java/io/undertow/util/HttpString.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/core/src/main/java/io/undertow/util/HttpString.java b/core/src/main/java/io/undertow/util/HttpString.java
index cc75a0b..d21257c 100644
--- a/core/src/main/java/io/undertow/util/HttpString.java
+++ b/core/src/main/java/io/undertow/util/HttpString.java
@@ -335,7 +335,9 @@ public final class HttpString implements Comparable<HttpString>, Serializable
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
ois.defaultReadObject();
try
+ hashCodeField.setAccessible(true);
hashCodeField.setInt(this, calcHashCode(bytes));
+ hashCodeField.setAccessible(false);
catch (IllegalAccessException e)
throw new IllegalAccessError(e.getMessage());
--
2.5.0
【问题讨论】:
【参考方案1】:此问题已在 Wildfly 中修复,请参阅 fix。
【讨论】:
以上是关于集群 Wildfly 抛出 java.lang.IllegalAccessError的主要内容,如果未能解决你的问题,请参考以下文章