1

I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK.

java.lang.ExceptionInInitializerError 
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
    at com.chubb.prssearchpolicy.test.PRSSearchPolicyResourceTest.init(PRSSearchPolicyResourceTest.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
    at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
    at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
    at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
    at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
    at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    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.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
    at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:136)
    at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:53)
    at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
    at mockit.Invocations.<clinit>(Invocations.java:26)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    ... 24 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.<init>(WindowsVirtualMachine.java:64)
    at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:64)
    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:213)
    at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:133)
    ... 29 more

For This I passes VM argument in run configuration but getting following error:

JVMJ9VM007E Command-line option unrecognised: -javaagent=C:\Users\junit\jmockit.jar

Has anyone faced this issue? Response will be greatly appreciated.

Ion Cojocaru
  • 2,583
  • 15
  • 16
Rupali
  • 11
  • 2

1 Answers1

0

Can you try adding the following parameter -Dcom.ibm.tools.attach.enable=yes also jdk tools.jar file should be in your classpath

Also please have a look into this post which is strikingly similar to yours. According to the accepted answer there was a bug in one of the distributions which needs to have TestNG in the classpath as workaround. AttachNotSupportedException while running jMockit tests on IBM JRE

Community
  • 1
  • 1
Alexander Petrov
  • 9,204
  • 31
  • 70