Query Process fails to start intermittently due to access issues in Java 9 and later

Condition

When running a Hue service on Java 9 or later, you may encounter IllegalAccessError exceptions related to module access restrictions. These errors occur because certain internal Java classes (e.g., sun.net.util.IPAddressUtil) are not accessible by default due to Java’s module system.

Example Error Messages:
[Guice/ErrorInjectingConstructor]: IllegalAccessError: class SecurityUtil$QualifiedHostResolver (in unnamed module @0x31c88ec8) 
cannot access class IPAddressUtil (in module java.base) 
because module java.base does not export sun.net.util to unnamed module @0x31c88ec8

Cause

Starting with Java 9, the Java Platform Module System restricts access to internal Java classes. If your application relies on these internal classes, the JVM throws an IllegalAccessError unless the module explicitly exports the necessary packages.

Solution

  1. Log in to Cloudera Manager as an Administrator.
  2. Go to Clusters > Hue service > Configuration > query_processor_java_opts option.
  3. Add JVM arguments to allow access.
    --add-exports java.base/sun.net.dns=ALL-UNNAMED --add-exports java.base/sun.net.util=ALL-UNNAMED
    
  4. Click Save Changes.
  5. Restart the Hue service.