Welcome to Questions - Ask OpenNMS, where you can ask questions and receive answers from other members of the community.

CentOS install fails with java class issues

+1 vote
294 views

Hi

New user, fairly recent Linux convert. I am attempting to install OpenNMS on my Centos 7 system.

I have followed the install guide through setting JAVA_HOME, PATH and I've also added CLASSPATH.

However here's my errors after running install, and then attempting to start:
 


[root@oxmbyrn-centos oxmbyrn]# opennms status
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at org.opennms.bootstrap.Bootstrap.executeClass(Bootstrap.java:458)
        at org.opennms.bootstrap.Bootstrap.executeClass(Bootstrap.java:420)
        at org.opennms.bootstrap.Bootstrap.main(Bootstrap.java:416)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:814)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 8 more
Unknown return code from doStatus: 1

at the end of attempt to install

==============================================================================
OpenNMS Upgrader
==============================================================================

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.opennms.bootstrap.Bootstrap$4.run(Bootstrap.java:464)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
        at org.opennms.netmgt.vmmgr.ControllerUtils.getController(ControllerUtils.java:48)
        at org.opennms.upgrade.support.Upgrade.isOpennmsRunning(Upgrade.java:110)
        at org.opennms.upgrade.support.Upgrade.execute(Upgrade.java:233)
        at org.opennms.upgrade.support.Upgrade.main(Upgrade.java:266)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:814)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 10 more

extract from /etc/profile

export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-2.b11.el7_3.x86_64/jre"
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH="/opt/opennms/system/javax"

[root@oxmbyrn-centos oxmbyrn]# journalctl -xe
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at org.opennms.bootstrap.Bootstrap.executeClass(Bootstrap.java:458)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at org.opennms.bootstrap.Bootstrap.executeClass(Bootstrap.java:420)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at org.opennms.bootstrap.Bootstrap.main(Bootstrap.java:416)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.Atta
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:814)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: ... 8 more
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: Unknown value return from doStatus: 1
May 04 16:48:23 oxmbyrn-centos.oxad.net opennms[9966]: [FAILED]
May 04 16:48:23 oxmbyrn-centos.oxad.net systemd[1]: opennms.service: control process exited, code=exited status=1
May 04 16:48:23 oxmbyrn-centos.oxad.net systemd[1]: Failed to start OpenNMS server.
-- Subject: Unit opennms.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit opennms.service has failed.
--
-- The result is failed.
May 04 16:48:23 oxmbyrn-centos.oxad.net systemd[1]: Unit opennms.service entered failed state.
May 04 16:48:23 oxmbyrn-centos.oxad.net systemd[1]: opennms.service failed.
May 04 16:48:23 oxmbyrn-centos.oxad.net polkitd[986]: Unregistered Authentication Agent for unix-process:9960:268369 (system
lines 2761-2783/2783 (END)

Hoping someone can help?

Thanks!

OpenNMS version
19.0.1-1
Java version
Oracle JDK 1.8.0.131-2
Operating system
Centos 7
PostgreSQL version
9.2.18-1.el7
asked May 6 by mgb1980 (210 points)
edited May 6 by indigo

1 Answer

0 votes
 
Best answer

Hi,

it seems like you have an OpenJDK Runtime Engine installed. It is required to install an OpenJDK Development Kit. In case you have installed a CentOS with graphical user interface there is probably a dependency to OpenJDK installed with the graphical interface. Can you make sure you have the right JDK installed? There is also an install script which installs everything for you on a minimal server without a graphical user interface which you can find here: https://www.opennms.org/en/install-centos

Please make sure you have java-1.8.0-openjdk-devel.x86_64    1:1.8.0.131-2.b11.el7_3 installed. You can verify by running the command 

yum list installed | grep openjdk.

Hope this helps

Ronny

answered May 6 by indigo (11,140 points)
selected May 8 by mgb1980
I checked and had the right JDK installed but still had same issues.
So I decided to install the dev version of JDK 1.8.0 x86-64. I ran the install script again and ran through without a hitch. Might be worth a note in the install docs.

I installed the JDK from standard repos, RHEL and Oracle and nothing worked until using the dev package.
Documented here: https://issues.opennms.org/browse/NMS-9327 Thank you for feedback.
Hello,

Could you add installing Java 1.8.0 JDK Devel as an additional step to the install guide located here: https://www.opennms.org/en/install-centos ?

Only after installing the following packages was I able to get the install script to complete properly:
java-1.8.0-openjdk-devel
java-1.8.0-openjdk-devel-debug
java-1.8.0-openjdk-debug
java-1.8.0-openjdk
java-1.8.0-openjdk-headless-debug

I'm not sure if I needed all 5 of these packages but at least one of these allowed the automated script to finish.

I'm running CentOS 7.4 patch as of 5 Nov 2017.

Thanks,

Rob
I tried the install script on a latest CentOS 7 Core and worked fine.

cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

The yum opennms package has a dependency against jdk1.8.0_144.x86_64 which is installed from the @opennms-repo-stable-common. If you have a graphical UI installed, it is possible you have already a Java Runtime installed and installing the opennms package will not install any other Java package.

In general it is recommended to use the Oracle JDK for production or mission critical environments. If you just test, the java-1.8.0-openjdk-devel is enough.

You can set the Java environment with the runjava command in the OpenNMS bin directory.
...