In a production environment we have a simple Zabbix monitoring system that works very well to collect metrics from various Tomcat instances and other Java applications.
In short, this is our current configuration (that is somehow classic):
[ Zabbix Server ] → [ Zabbix Agent (passive) ] → [ Zabbix Java Gateway ] → [ Tomcat ] It works also in this way:
[ Zabbix Server ] ← [ Zabbix Proxy ] → [ Zabbix Agent (passive) ] → [ Zabbix Java Gateway ] → [ Tomcat ] The above configuration works out of the box for us with any native package in the following distributions at least:
- Debian GNU/Linux 11 (current stable) (https://packages.debian.org/bullseye/zabbix-java-gateway)
- Ubuntu 20.04 (current LTS) (https://packages.ubuntu.com/focal/zabbix-java-gateway)
- Ubuntu 22.04 (current LTS) (https://packages.ubuntu.com/jammy/zabbix-java-gateway)
This is an example of how we suggest to install the agents:
sudo apt install zabbix-agent zabbix-java-gateway The problem
For application reasons we now need a custom Java JDK. But, that is not compatible with the Zabbix Java Gateway.
For example if we configure one Java JDK in a non-standard place, to avoid any possible conflict with existing packages, and if then we set that as default, like in this way:
update-alternatives --install /usr/bin/java java /opt/jdk-production/bin/java 2222 update-alternatives --config java From that point, the systemd daemon of zabbix-java-gateway stops working.
This is the following stack trace:
$ journalctl -fu zabbix-java-gateway Apr 27 16:09:22 example-hostname systemd[1]: Starting Zabbix Java Gateway... Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: Error: A JNI error has occurred, please check your installation and try again Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/zabbix/gateway/JavaGateway has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.lang.ClassLoader.defineClass1(Native Method) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.lang.ClassLoader.defineClass(ClassLoader.java:756) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.net.URLClassLoader.access$100(URLClassLoader.java:74) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.net.URLClassLoader$1.run(URLClassLoader.java:369) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.net.URLClassLoader$1.run(URLClassLoader.java:363) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.security.AccessController.doPrivileged(Native Method) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.net.URLClassLoader.findClass(URLClassLoader.java:362) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.lang.ClassLoader.loadClass(ClassLoader.java:418) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at java.lang.ClassLoader.loadClass(ClassLoader.java:351) Apr 27 16:09:22 example-hostname zabbix_java_gateway[956]: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601) Apr 27 16:09:22 example-hostname zabbix_java_gateway[947]: Zabbix Java Gateway did not start Apr 27 16:09:22 example-hostname systemd[1]: zabbix-java-gateway.service: Control process exited, code=exited, status=1/FAILURE Apr 27 16:09:22 example-hostname systemd[1]: zabbix-java-gateway.service: Failed with result 'exit-code'. Apr 27 16:09:22 example-hostname systemd[1]: Failed to start Zabbix Java Gateway. So, the package is clearly not compatible with our JDK based on Java 8.
In short, we would like to:
- just fix the Zabbix Java Gateway
- possibly, avoid to install non-native packages (avoid to install another Zabbix Java Gateway)
- possibly, keep our custom Java version as the default one
Question
What is the Debian-way or Ubuntu-way to fix similar issues with the Zabbix Java Gateway?