环境说明:换电脑尝尝鲜,jdk,flink都是最新的,千辛万苦把之前的项目编译通过,跑一下之前的flink项目发现启动失败,啥都不说了上异常
Exception in thread "main" java.lang.IllegalAccessError: class org.apache.flink.util.NetUtils (in unnamed module @0x311bf055) cannot access class sun.net.util.IPAddressUtil (in module java.base) because module java.base does not export sun.net.util to unnamed module @0x311bf055
at org.apache.flink.util.NetUtils.unresolvedHostToNormalizedString(NetUtils.java:146)
at org.apache.flink.util.NetUtils.unresolvedHostAndPortToNormalizedString(NetUtils.java:174)
at org.apache.flink.runtime.clusterframework.BootstrapTools.startActorSystem(BootstrapTools.java:243)
at org.apache.flink.runtime.clusterframework.BootstrapTools.startActorSystem(BootstrapTools.java:153)
at org.apache.flink.runtime.rpc.akka.AkkaRpcServiceUtils.createRpcService(AkkaRpcServiceUtils.java:125)
at org.apache.flink.runtime.metrics.util.MetricUtils.startMetricsRpcService(MetricUtils.java:129)
at org.apache.flink.runtime.minicluster.MiniCluster.start(MiniCluster.java:291)
at org.apache.flink.client.LocalExecutor.createJobExecutorService(LocalExecutor.java:143)
at org.apache.flink.client.LocalExecutor.start(LocalExecutor.java:118)
at org.apache.flink.client.LocalExecutor.executePlan(LocalExecutor.java:203)
at org.apache.flink.api.java.LocalEnvironment.execute(LocalEnvironment.java:91)
at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:820)
at org.apache.flink.api.java.DataSet.collect(DataSet.java:413)
at org.apache.flink.api.java.DataSet.print(DataSet.java:1652)
at com.gugu.flink.BatchWordCount.main(BatchWordCount.java:29)
分析:jdk添加模块化功能之后,跨模块访问
解决方案:
-
回退jdk版本,退退退。。。
-
临时可以添加参数,允许其他模块访问
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED
注意是idea中的Add vm options 选项,又是被代码调戏的一天