"Inaccessible Object" exception while using JDK11

Description

If you are using JDK11 in a Linux environment and have the LCS 5.0.0 client deployed, you may receive the following error on startup:

ERROR [LCS Worker 2][BaseScheduledTask:92] java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount() accessible: module jdk.management does not
 "opens com.sun.management.internal" to unnamed module @1a3325e5
java.lang.reflect.InaccessibleObjectException: Unable to make public long com.sun.management.internal.OperatingSystemImpl.getOpenFileDescriptorCount() accessible: module jdk.management does not "opens com.sun.management.internal" to unnamed module @1a3325e5
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198) at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)

Resolution

This error occurs because JDK11 was recently added to the compatibility matrix. The following are workarounds for the Tomcat and Wildfly app servers

If you are migrating to JDK11 please also the reference the Illegal Access Warning known issue article.

Tomcat

Add these properties to Tomcat (e.g. tomcat/bin/setenv.sh) to avoid illegal access warning messages:

CATALINA_OPTS=
CATALINA_OPTS="$CATALINA_OPTS --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED"

Wildfly

Add these properties to Wildfly (e.g. wildfly/bin/standalone.conf) to avoid illegal access warning messages:

JAVA_OPTS="$JAVA_OPTS --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED"
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0