ClassNotFoundException: com.sun.tools.attach.VirtualMachine
dlwester Jul 13, 2015 2:55 PMI am trying to run my integration tests via a Jenkins build using Maven running JUnit and Arquillian. When I run on my local Windows machine, everything runs fine (without Jenkins). But when I try to build using Jenkins on Linux, I am getting the following error:
com.ibm.myw3.services.taskcalendar.ejb.test.TaskCalendarManagerIT
com.ibm.myw3.services.taskcalendar.ejb.test.TaskCalendarManagerIT Time elapsed: 0.446 sec <<< ERROR!
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160)
...
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:86)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:58)
at java.lang.reflect.Constructor.newInstance(Constructor.java:542)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)
...
Caused by: java.lang.NoClassDefFoundError: com.sun.tools.attach.VirtualMachine
at java.lang.Class.getDeclaredMethodsImpl(Native Method)
at java.lang.Class.getDeclaredMethods(Class.java:986)
at org.jboss.arquillian.core.impl.Reflections.getObserverMethods(Reflections.java:52)
at org.jboss.arquillian.core.impl.ExtensionImpl.of(ExtensionImpl.java:55)
at org.jboss.arquillian.core.impl.ManagerImpl.inject(ManagerImpl.java:211)
at org.jboss.arquillian.core.impl.InjectorImpl.inject(InjectorImpl.java:58)
at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.createServiceInstance(ServiceRegistryLoader.java:108)
at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.all(ServiceRegistryLoader.java:55)
...
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:941)
at java.lang.ClassLoader.loadClass(ClassLoader.java:868)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)
at java.lang.ClassLoader.loadClass(ClassLoader.java:846)
at java.lang.Class.getDeclaredMethodsImpl(Native Method)
at java.lang.Class.getDeclaredMethods(Class.java:986)
at org.jboss.arquillian.core.impl.Reflections.getObserverMethods(Reflections.java:52)
None of my other colleagues are getting this error when running in the same environment, so I'm not sure if my Arquillian tests are using some other functionality that no one else is.
That "missing" 'tools.jar' file is in the JDK that I am using (and yes, I have verified that the correct JDK is being used). I've even tried to add the jar to the CLASSPATH of the running Maven step, but nothing resolves the error.
Does this look familiar to anyone? Does that 'VirtualMachine' class only get called under certain circumstances? Does anyone know what those circumstances are? I'm going under the assumption that my code is the only one that is causing that class to be loaded, and none of my colleagues are - but that might be a bad assumption.