启动flink时遭遇类型转换异常无法解决?

一、现象

    启动flink时遭遇类型转换异常,异常信息如下:

java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')
        at akka.remote.artery.FastHash$.ofString(LruBoundedCache.scala:18)
        at akka.remote.serialization.ActorRefResolveCache.hash(ActorRefResolveCache.scala:61)
        at akka.remote.serialization.ActorRefResolveCache.hash(ActorRefResolveCache.scala:55)
        at akka.remote.artery.LruBoundedCache.getOrCompute(LruBoundedCache.scala:110)
        at akka.remote.RemoteActorRefProvider.resolveActorRef(RemoteActorRefProvider.scala:403)
        at akka.actor.SerializedActorRef.readResolve(ActorRef.scala:433)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1250)
        at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2096)
        at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1594)
        at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2355)
        at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2249)
        at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2087)
        at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1594)
        at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2355)
        at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2249)
        at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2087)
        at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1594)
        at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at akka.serialization.JavaSerializer.$anonfun$fromBinary$1(Serializer.scala:328)
        at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
        at akka.serialization.JavaSerializer.fromBinary(Serializer.scala:328)
        at akka.serialization.Serialization.deserializeByteArray(Serialization.scala:156)
        at akka.serialization.Serialization.$anonfun$deserialize$2(Serialization.scala:142)
        at scala.util.Try$.apply(Try.scala:209)
        at akka.serialization.Serialization.deserialize(Serialization.scala:136)
        at akka.remote.MessageSerializer$.deserialize(MessageSerializer.scala:33)
        at akka.remote.DefaultMessageDispatcher.payload$lzycompute$1(Endpoint.scala:64)
        at akka.remote.DefaultMessageDispatcher.payload$1(Endpoint.scala:64)
        at akka.remote.DefaultMessageDispatcher.dispatch(Endpoint.scala:82)
        at akka.remote.EndpointReader$$anonfun$receive$2.applyOrElse(Endpoint.scala:982)
        at akka.actor.Actor.aroundReceive(Actor.scala:502)
        at akka.actor.Actor.aroundReceive$(Actor.scala:500)
        at akka.remote.EndpointActor.aroundReceive(Endpoint.scala:446)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
        at akka.actor.ActorCell.invoke(ActorCell.scala:495)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
        at akka.dispatch.Mailbox.run(Mailbox.scala:224)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

    在网上找了很久没有找到解决办法,无奈又在官网上仔细看了看教程,检查是不是中间有哪个环节出现了问题,结果果然看出了端倪。

二、解决办法

    在官网的教程上看到了如下信息:

3079364f272b70dcd6e7a0986c6e684d651.jpg

    关键就在"have a working Java8.x installation",这句话中并没有"or higher"之类的字眼,所以我推断当前版本的flink只能在Java8上工作,而我的JDK版本是Java11,抱着试一试的心态把JDK版本降为了Java8,再次启动flink,成功。所以遇到类似问题的朋友可以检查一下你们的JDK版本是否匹配。

转载于:https://my.oschina.net/jack90john/blog/3061497

你可能感兴趣的:(启动flink时遭遇类型转换异常无法解决?)