I am working in a “biggish” Maven/Java project and cannot make sense of an error I am getting when running the app (it compiles OK). The error code I get is:
java.lang.NoClassDefFoundError: Could not initialize class com.sun.management.OperatingSystem
at com.sun.management.OSMBeanFactory.getOperatingSystemMXBean(OSMBeanFactory.java:30)
at sun.management.ManagementFactory.getOperatingSystemMXBean(ManagementFactory.java:100)
at sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:308)
at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:504)
at com.sun.xml.internal.ws.server.JMXAgent.<init>(JMXAgent.java:49)
at com.sun.xml.internal.ws.server.JMXAgent.getDefault(JMXAgent.java:77)
at com.sun.xml.internal.ws.server.WSEndpointImpl.<clinit>(WSEndpointImpl.java:84)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
From the look of it, it seems the VM is not finding the “com.sun.management.OperatingSystem” class, but after googling around I cannot find out where is that class supposed to be located.
Any hints?
EDIT: Running with JRE JDK 1.6.0_18 (JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18)
It might not be what’s causing your problem, but errors like the one you are seeing can sometimes occur when the JDK is stored under “Program Files”. Java doesn’t like spaces in the filesystem path.