Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 17 solution for Spark - java.lang.NoClassDefFoundError: Could not initialize class org.apache.spark.storage.StorageUtils

There are some solutions here

Windows Spark Error java.lang.NoClassDefFoundError: Could not initialize class org.apache.spark.storage.StorageUtils

The mentioned error probably corresponds to the following exception:

java.lang.IllegalAccessError: class org.apache.spark.storage.StorageUtils$ (in unnamed module @0x12a94400) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module

Switching back to Java 11 or below is not a solution for me. How can this be solved with Java 17?

like image 577
Arnd Eden Avatar asked Dec 19 '25 12:12

Arnd Eden


1 Answers

You can solve this problem (and about each and every Java 17 problem) by adding a --add-exports statement to the corresponding Java call. In this case --add-exports java.base/sun.nio.ch=ALL-UNNAMED.

like image 175
2 revs, 2 users 67%OneCricketeer Avatar answered Dec 21 '25 04:12

2 revs, 2 users 67%OneCricketeer