Installing OpenNMS fails with ClassNotFoundException:


When you try to install OpenNMS you get an exception during the initialisation of the database with the following content:

INFO 12/7/18 1:45 PM:liquibase: Successfully released change log lock
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.opennms.bootstrap.Bootstrap$
Caused by: java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
	at org.opennms.netmgt.vmmgr.ControllerUtils.getController(
	... 6 more
Caused by: java.lang.ClassNotFoundException:
	at java.lang.ClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 10 more

If you run from the installer script the output looks like this.

PostgreSQL initialize                 ... OK
PostgreSQL set auth from ident to md5 ... OK
Start PostgreSQL database             ... OK
PostgreSQL systemd enable             ... OK

Enter database username: mydb
Enter database password:

Generate OpenNMS data source config   ... OK
Initialize OpenNMS                    ... FAILED


When you run the installer scripts you will find this exception in the bootstrap.log file. Check if you have a “javac” binary available and it is in major version 8.

You can check which Java environment is used from OpenNMS and the installer when you run:

${OPENNMS_HOME}/bin/runjava -c

You should be able the javac binary in the major version 8 is available on your system. You can test it with:

javac -version

You can check the installed Java versions:


yum list installed | grep java

modern Debian/Ubuntu:

apt list --installed java

older Debian/Ubuntu:

dpkg --get-selections | grep -v deinstall | grep openjdk


OpenNMS requires to have a Java Development Kit. A Java Runtime Environment is not enough. During the installation OpenNMS checks a general Java dependency. When you install on a Server with a GUI, it installs automatically a Java Runtime Environment which satisfies this dependency and OpenNMS will not change your Java environment and uses the existing one.


Install a Java Development Kit and make sure it is used from the OpenNMS installer. The Java Development Kit for OpenJDK is named java-1.8.0-openjdk-devel and on Ubuntu/Debian openjdk-8-jdk. If you have multiple Java environments installed you can run ${OPENNMS_HOME}/bin/runjava -S <JRE path> to set the appropriate Java environment and run the installer again.

Hrrrm. The /opt/opennms/bin/runjava command is supposed to make sure there is a valid environment, yet is passes on CentOS 8 with no JDK installed. Shouldn’t this be a bug for runjava?

This is a good question - the runjava which calls became pretty complex scripts over the the last decades just to make an entry in java.conf. I can’t easily figure out what the intended behavior is from this two scripts to tell you if this is a bug or not. On startup I would vote to do what all Java apps do these days:

  1. Use JAVA_HOME#
  2. If unset, use search path
  3. bail and tell admin what to do to set a working Java environment