Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
917 views
in Technique[技术] by (71.8m points)

netty - java.lang.IllegalAccessError when using vertx web client version 4.0.0

Using vertx 4.0.0 with jdk 14. I'm getting the following exception when trying to make a REST request using the vertx web client:

15:56:48.294 [vert.x-eventloop-thread-0] ERROR io.vertx.core.impl.ContextImpl - Unhandled exception
java.lang.IllegalAccessError: class io.vertx.core.buffer.impl.VertxUnsafeHeapByteBuf cannot access its superclass io.netty.buffer.UnpooledUnsafeHeapByteBuf (io.vertx.core.buffer.impl.VertxUnsafeHeapByteBuf and io.netty.buffer.UnpooledUnsafeHeapByteBuf are in unnamed module of loader 'app')
        at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[?:?]
        at jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) ~[?:?]
        at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) ~[?:?]
        at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) ~[?:?]
        at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) ~[?:?]
        at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
        at io.vertx.core.buffer.impl.VertxByteBufAllocator.<clinit>(VertxByteBufAllocator.java:20) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.buffer.impl.BufferImpl.<init>(BufferImpl.java:64) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.buffer.impl.BufferImpl.<init>(BufferImpl.java:60) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.buffer.impl.BufferImpl.buffer(BufferImpl.java:38) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.buffer.Buffer.buffer(Buffer.java:49) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.codec.impl.BodyCodecImpl$1.<init>(BodyCodecImpl.java:88) ~[vertx-web-common-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.codec.impl.BodyCodecImpl.create(BodyCodecImpl.java:86) ~[vertx-web-common-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.handleReceiveResponse(HttpContext.java:427) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.execute(HttpContext.java:338) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.next(HttpContext.java:322) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.fire(HttpContext.java:289) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.receiveResponse(HttpContext.java:238) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.ext.web.client.impl.HttpContext.lambda$null$13(HttpContext.java:564) ~[vertx-web-client-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:125) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:61) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:180) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.Promise.complete(Promise.java:66) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.HttpClientRequestImpl.handleResponse(HttpClientRequestImpl.java:350) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.HttpClientRequestBase.handleResponse(HttpClientRequestBase.java:185) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.HttpClientRequestBase.lambda$new$0(HttpClientRequestBase.java:71) ~[vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.ContextImpl.emit(ContextImpl.java:294) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:24) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.Http1xClientConnection$StreamImpl.handleHead(Http1xClientConnection.java:537) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.Http1xClientConnection.handleResponseBegin(Http1xClientConnection.java:695) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.Http1xClientConnection.handleHttpMessage(Http1xClientConnection.java:628) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.http.impl.Http1xClientConnection.handleMessage(Http1xClientConnection.java:602) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:151) [vertx-core-4.0.0.jar:4.0.0]
        at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:144) [vertx-core-4.0.0.jar:4.0.0]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:426) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1476) [netty-handler-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1225) [netty-handler-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1272) [netty-handler-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) [netty-codec-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-common-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.34.Final.jar:4.1.34.Final]
        at java.lang.Thread.run(Thread.java:832) [?:?]

Looking more closely at the error it appears that indeed the Vertx class VertxUnsafeHeapByteBuf is inheriting from the Netty class UnpooledUnsafeHeapByteBuf which has a package level access level. ( in other words it's not a public class) The Netty library version maven resolves it as "4.1.34.Final".

I tried to exclude this version of the Netty library and use a newer version which has the UnpooledUnsafeHeapByteBuf class with public accessor. so I used "4.1.58.Final" which is the latest, and while I no longer getting the IllegalAccessError unfortunately it still does not work with the following stacktrace:

io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Search domain query failed. Original hostname: 'usapi.alibaba.com' failed to resolve 'usapi.alibaba.com' after 2 queries 
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:877)
    at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:838)
    at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:333)
    at io.netty.resolver.dns.DnsResolveContext.access$600(DnsResolveContext.java:63)
    at io.netty.resolver.dns.DnsResolveContext$3.operationComplete(DnsResolveContext.java:382)
    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:502)
    at io.netty.util.co

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Until vert.x will release a fix for this issue. For the time being the suggestion made by Aniket Sahrawat resolved the issue. which is to include the following dependency in your POM file:

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.48.Final</version>
</dependency>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...