kpavlov / jreactive-8583

Kotlin/Java Client & Server for ISO8583 & Netty
Apache License 2.0
320 stars 144 forks source link

"Exception in thread "main" io.netty.handler.codec.EncoderException: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer" when calling client.send() #82

Closed ODRIN7 closed 4 years ago

ODRIN7 commented 4 years ago

I am triing to call send() on Iso8583Client and i got below exception with java 1.8. If i call send() with jdk-13.0.2, its working "Exception in thread "main" io.netty.handler.codec.EncoderException: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer"

full stackstrace: [main] INFO com.github.kpavlov.jreactive8583.server.Iso8583Server - Initializing [main] WARN io.netty.bootstrap.ServerBootstrap - Unknown channel option 'TCP_NODELAY' for channel '[id: 0x0c3503bf]' [nioEventLoopGroup-2-1] INFO com.github.kpavlov.jreactive8583.server.Iso8583Server - Server is started and listening at /0:0:0:0:0:0:0:0:8081 [main] INFO com.github.kpavlov.jreactive8583.client.Iso8583Client - Initializing Exception in thread "main" io.netty.handler.codec.EncoderException: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:125) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:715) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:707) at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1087) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; at com.solab.iso8583.IsoMessage.writeToBuffer(IsoMessage.java:377) at com.github.kpavlov.jreactive8583.netty.codec.Iso8583Encoder.encode(Iso8583Encoder.java:26) at com.github.kpavlov.jreactive8583.netty.codec.Iso8583Encoder.encode(Iso8583Encoder.java:11) at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107)

sayseakleng commented 4 years ago

I temporarily fix this by enabling encodeFrameLengthAsString (0041 where 41 is a length of data)

val config = com.github.kpavlov.jreactive8583.server.ServerConfiguration.newBuilder() .replyOnError(Boolean.TRUE) .encodeFrameLengthAsString(Boolean.TRUE) .frameLengthFieldLength(4) .build();

This issue caused by com.solab.iso8583.IsoMessage.writeToBuffer(int) method, where jreactive-8583 called to com.github.kpavlov.jreactive8583.netty.codec.Iso8583Encoder.encode(ChannelHandlerContext, IsoMessage, ByteBuf) Therefore. jreactive-8583 should avoid calling this method. ( I already separately report this issue to solab.iso8583.

I really appreciate your contribution to this library. Looks forward to getting the fix for future release.

Best Regard,

Reno

kpavlov commented 4 years ago

Support for JDK 1.8 will be dropped in next release