Tomcat with Java 17+

Deploying i-net Clear Reports reporting.war in Tomcat may result in errors in the log file:

[Config,ERROR ,9/28 9:37:16,#00002] java.lang.reflect.InaccessibleObjectException: Unable to make field static java.util.Hashtable java.net.URL.handlers accessible: module java.base does not "opens java.net" to unnamed module @447582b6
...
[Config,ERROR ,9/28 9:37:16,#00002] Could not register the URL protocol: data
[Config,ERROR ,9/28 9:37:16,#00002] java.net.MalformedURLException: unknown protocol: data
...
[Config,ERROR ,8/6 11:04:05,#00001] Could not register the URL protocol: drive
[Config,ERROR ,8/6 11:04:05,#00001] java.net.MalformedURLException: unknown protocol: drive

The solution requires to add java.base/java.net to the allowed modules. You can do this in the following ways:

Windows

You have to update the catalina.bat with the following JDK_JAVA_OPTIONS:

set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.net=ALL-UNNAMED"

# Tomcat 10+
set "JAVA_OPTS=%JAVA_OPTS% --add-opens=java.base/java.net=ALL-UNNAMED"

Now restart the server.

Linux / macOS

You have to update the catalina.sh with the following JDK_JAVA_OPTIONS:

JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.net=ALL-UNNAMED"

# Tomcat 10+
JAVA_OPTS="$JAVA_OPTS --add-opens=java.base/java.net=ALL-UNNAMED"

Now restart the server.

Docker Container

In a Docker container, where the Tomcat is installed, it may suffice to set the environment variable, e.g. using:

export JDK_JAVA_OPTIONS="--add-opens=java.base/java.net=ALL-UNNAMED"

# Tomcat 10+
export JAVA_OPTS="--add-opens=java.base/java.net=ALL-UNNAMED"