简体   繁体   English

java.lang.AbstractMethodError:io.netty.handler.codec.http.DefaultFullHttpRequest.touch(Ljava/lang/Object;)Lio/netty/util/ReferenceCounted

[英]java.lang.AbstractMethodError: io.netty.handler.codec.http.DefaultFullHttpRequest.touch(Ljava/lang/Object;)Lio/netty/util/ReferenceCounted

I'm new to the world of Java and trying to send a Https request.我是 Java 世界的新手,并试图发送 Https 请求。 When I try to send a request through the channel I get the following error当我尝试通过通道发送请求时,出现以下错误

java.lang.AbstractMethodError:io.netty.handler.codec.http.DefaultFullHttpRequest.touch(Ljava/lang/Object;)Lio/netty/util/ReferenceCounted

Here is my pipeline code这是我的管道代码

if (sslCtx != null) {
                         ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()));
                     }

                     ch.pipeline().addLast(new HttpClientCodec());

                     ch.pipeline().addLast(new HttpContentDecompressor());

                     ch.pipeline().addLast(new HttpObjectAggregator(1048576));
                     ch.pipeline().addLast("encoder", new HttpRequestEncoder());
                     ch.pipeline().addLast(new ClientHandler());

Here is my bootstrap code这是我的引导代码

ChannelFuture f = b.connect(host, port).sync(); 

             ByteBuf bbuf = Unpooled.copiedBuffer(message, StandardCharsets.UTF_8);

             FullHttpRequest request = new DefaultFullHttpRequest(
                     HttpVersion.HTTP_1_1, HttpMethod.POST, uri,bbuf,Boolean.FALSE);
             request.headers().set(HttpHeaders.Names.HOST, host);
             request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
             request.headers().set(HttpHeaders.Names.CONTENT_LENGTH, bbuf.readableBytes());
             ((DefaultFullHttpRequest) request).content().clear().writeBytes(bbuf);

             f.channel().writeAndFlush(request);

Stacktrace:堆栈跟踪:

Exception in thread "main" java.lang.AbstractMethodError: io.netty.handler.codec.http.DefaultFullHttpRequest.touch(Ljava/lang/Object;)Lio/netty/util/ReferenceCounted;
    at io.netty.util.ReferenceCountUtil.touch(ReferenceCountUtil.java:73)
    at io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:107)
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:821)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:805)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:842)
    at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1032)
    at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:296

Context: Trying to send an HTTPS request上下文:尝试发送 HTTPS 请求

What am I doing wrong?我究竟做错了什么?

This is most likely because you have multiple Netty 4.x dependency versions on your class path.这很可能是因为您的 class 路径上有多个 Netty 4.x 依赖版本。 Just ensure you only have the latest on the class path and it should work只要确保您只有 class 路径上的最新版本,它应该可以工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoSuchMethodError: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId; - java.lang.NoSuchMethodError: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId; java.lang.NoSuchMethodError:io.netty.buffer.PooledByteBufAllocator.metric()Lio / netty / buffer / PooledByteBufAllocatorMetric; - java.lang.NoSuchMethodError: io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetric; XPages 运行时错误:java.lang.AbstractMethodError: lotus/domino/RichTextItem.convertToHTML(Ljava/util/Vector;)Ljava/lang/String; - XPages runtime error: java.lang.AbstractMethodError: lotus/domino/RichTextItem.convertToHTML(Ljava/util/Vector;)Ljava/lang/String; java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getClientInfo()Ljava/util/Properties; - java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getClientInfo()Ljava/util/Properties; java.lang.AbstractMethodError - java.lang.AbstractMethodError 关于错误“线程“ main”中的异常”的问题java.lang.NoSuchMethodError:io.netty.resolver.HostsFileParser.parseSilently()Ljava / util / Map;” - problems about error “Exception in thread ”main“ java.lang.NoSuchMethodError: io.netty.resolver.HostsFileParser.parseSilently()Ljava/util/Map;” 处理程序调度失败; 嵌套的异常是java.lang.AbstractMethodError:javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava / lang / String; Z)V - Handler dispatch failed; nested exception is java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.NoClassDefFoundError:io / netty / util / concurrent / RejectedExecutionHandlers - java.lang.NoClassDefFoundError: io/netty/util/concurrent/RejectedExecutionHandlers 线程“主”中的异常 java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Ljava/util/List; - Exception in thread "main" java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Ljava/util/List; 使用IDEA开发时启动LoggerServer出错:io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: 非法包 - Error starting LoggerServer when using IDEA development : io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: illegal packet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM