Yugabyte-db: yb-client jar compiled against jdk 11 does not work with jdk 8

Created on 21 Dec 2020  路  2Comments  路  Source: yugabyte/yugabyte-db

Repro steps:

  1. Create a yb cluster locally at 127.0.0.1 by running yb-ctl or yugabyted
  2. Ensure java -version shows > Java 8 (Java 9 at least) and run ./yb_build.sh --java-only
  3. Install Java 8 in a different dir. Run <path to java8> -jar java/yb-cli/target/yb-cli-0.8.0-SNAPSHOT.jar. At the prompt, type the commands connect --masters 127.0.0.1:7100 and list masters
  4. See the error Failed to fetch masters info for database at 127.0.0.1:7100, error: com.stumbleupon.async.TimeoutException: Timed out after 10000ms when joining Deferred@503928724(state=RUNNING, result=tablet_locations { tablet_id: "YB Master" replicas { ts_info { permanent_uuid: "e4443d784f6847c08a792e6f2535f667" private_rpc_addresses { host: "127.0.0.1" port: 7100 } } role: LEADER } stale: false partition { partition_key_start: "" partition_key_end: "" } } , callback=release master lookup permit -> retry RPC -> wakeup thread Spring Shell, errback=release master lookup permit -> retry RPC after error -> wakeup thread Spring Shell)

The same error also repros through YW create universe.


When running with DEBUG logging the full details of the error are seen (ips are different):

2020-12-20 19:50:12 DEBUG TabletClient:606 - [Peer YB Master - 172.151.29.141:7100] [id: 0xd2aa4ea4, /10.150.0.148:43978 => /172.151.29.141:7100] EXCEPTION: java.lang.NoSuchMethodError: java.nio.CharBuffer.flip()Ljava/nio/CharBuffer;
2020-12-20 19:50:12 DEBUG TabletClient:700 - [Peer YB Master - 172.151.29.141:7100] Unexpected exception java.nio.CharBuffer.flip()Ljava/nio/CharBuffer; from downstream on [id: 0xd2aa4ea4, /10.150.0.148:43978 => /172.151.29.141:7100]
java.lang.NoSuchMethodError: java.nio.CharBuffer.flip()Ljava/nio/CharBuffer;
        at org.yb.util.Slices.decodeString(Slices.java:174)
        at org.yb.util.Slice.toString(Slice.java:705)
        at org.yb.util.Slice.toString(Slice.java:692)
        at org.yb.client.AsyncYBClient.discoverTablets(AsyncYBClient.java:1679)
        at org.yb.client.AsyncYBClient$MasterLookupCB.call(AsyncYBClient.java:1603)
        at org.yb.client.AsyncYBClient$MasterLookupCB.call(AsyncYBClient.java:1595)
        at com.stumbleupon.async.Deferred.doCall(Deferred.java:1280)
        at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
        at com.stumbleupon.async.Deferred.callback(Deferred.java:1002)
        at org.yb.client.GetMasterRegistrationReceived$GetMasterRegistrationCB.call(GetMasterRegistrationReceived.java:193)
        at org.yb.client.GetMasterRegistrationReceived$GetMasterRegistrationCB.call(GetMasterRegistrationReceived.java:165)
        at com.stumbleupon.async.Deferred.doCall(Deferred.java:1280)
        at com.stumbleupon.async.Deferred.runCallbacks(Deferred.java:1259)
        at com.stumbleupon.async.Deferred.callback(Deferred.java:1002)
        at org.yb.client.YRpc.handleCallback(YRpc.java:180)
        at org.yb.client.YRpc.callback(YRpc.java:193)
        at org.yb.client.TabletClient.decode(TabletClient.java:440)
        at org.yb.client.TabletClient.decode(TabletClient.java:98)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
        at org.yb.client.TabletClient.handleUpstream(TabletClient.java:608)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler.messageReceived(ReadTimeoutHandler.java:184)
        at org.yb.client.AsyncYBClient$TabletClientPipeline.sendUpstream(AsyncYBClient.java:2088)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

The reason for this error is that the flip method of CharBuffer has a different signature in Java 8 and Java 11 (returns ByteBuffer vs Buffer). This causes a "runtime link" error (a more accurate description is at https://github.com/apache/felix/pull/114).

@Arnav15

Most helpful comment

To prevent this, build with --release=8 instead of --source and --target. At Debezium, we also happened to run into this, and I blogged about it just today :)

All 2 comments

To prevent this, build with --release=8 instead of --source and --target. At Debezium, we also happened to run into this, and I blogged about it just today :)

@gunnarmorling : Your blog post is the clearest description of the underlying signature mismatch I've seen on this topic so far, thanks for writing it and pointing us to it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rkarthik007 picture rkarthik007  路  5Comments

joeblew99 picture joeblew99  路  5Comments

fabiocmazzo picture fabiocmazzo  路  4Comments

ajcaldera1 picture ajcaldera1  路  4Comments

fabiocmazzo picture fabiocmazzo  路  5Comments