title: AttachNotSupportedException while running jMockit tests on IBM JRE
body: <p>I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK. Has anyone faced this issue? I tried given <code>-Dcom.ibm.tools.attach.enable=yes</code> as VM argument but no luck. The same code is working fine in Sun JDK.</p>
  
  <pre><code>java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:89)
      at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
      at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
      at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:98)
      at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:112)
      at org.junit.runner.Runner.&lt;clinit&gt;(Runner.java:22)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
      at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.&lt;init&gt;(JUnit4TestReference.java:33)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.&lt;init&gt;(JUnit4TestClassReference.java:25)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
      at sun.tools.attach.WindowsVirtualMachine.&lt;init&gt;(WindowsVirtualMachine.java:64)
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:73)
      ... 22 more
  java.lang.NoClassDefFoundError: org.junit.internal.runners.ErrorReportingRunner (initialization failure)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.&lt;init&gt;(JUnit4TestReference.java:33)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.&lt;init&gt;(JUnit4TestClassReference.java:25)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: java.lang.NoClassDefFoundError: org.junit.runner.Runner (initialization failure)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      ... 9 more
  Caused by: java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:89)
      at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
      at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
      at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:98)
      at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:112)
      at org.junit.runner.Runner.&lt;clinit&gt;(Runner.java:22)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
      at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      ... 11 more
  Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
      at sun.tools.attach.WindowsVirtualMachine.&lt;init&gt;(WindowsVirtualMachine.java:64)
      at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:73)
      ... 22 more
  </code></pre>
  
  <p>I tried giving the VM argument <code>-javaagent:jmockit.jar</code> as suggested by Kevin Welker and I got the below exception.</p>
  
  <pre><code>Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:335)
      at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:350)
  Caused by: java.lang.NullPointerException
      at mockit.internal.annotations.MockClassSetup.validateRealClass(MockClassSetup.java:59)
      at mockit.internal.annotations.MockClassSetup.&lt;init&gt;(MockClassSetup.java:38)
      at mockit.internal.annotations.MockClassSetup.&lt;init&gt;(MockClassSetup.java:77)
      at mockit.internal.annotations.MockClassSetup.&lt;init&gt;(MockClassSetup.java:99)
      at mockit.internal.startup.JMockitInitialization.setUpInternalStartupMock(JMockitInitialization.java:56)
      at mockit.internal.startup.JMockitInitialization.initialize(JMockitInitialization.java:29)
      at mockit.internal.startup.Startup.initialize(Startup.java:68)
      at mockit.internal.startup.Startup.premain(Startup.java:56)
      ... 6 more
  
  Fatal error: processing of -javaagent failed
  </code></pre>