java - JVMJ9VM007E 命令行选项无法识别 : -javaagent

标签 java junit path jvm jmockit

当我尝试使用 IBM JDK 运行简单的 jMockit/JUnit 测试时,出现以下异常。

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

为此,我在运行配置中传递了 VM 参数,但出现以下错误:

JVMJ9VM007E 命令行选项无法识别:-javaagent=C:\Users\junit\jmockit.jar

有人遇到过这个问题吗?我们将不胜感激。

最佳答案

您可以尝试添加以下参数 -Dcom.ibm.tools.attach.enable=yes 并且 jdk tools.jar 文件也应该位于您的类路径中

另外,请查看这篇与您的文章惊人相似的文章。根据已接受的答案,其中一个发行版中存在一个错误,需要在类路径中包含 TestNG 作为解决方法。 AttachNotSupportedException while running jMockit tests on IBM JRE

关于java - JVMJ9VM007E 命令行选项无法识别 : -javaagent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38591002/

相关文章:

java - 获取从 HttpGet 发送的原始 HTTP 请求消息?

java - 使用JUnit @ResourceLock顺序执行一些测试类

python - 为什么 'C:' 不是我认为的意思?

windows - 如何在 Git Bash 中使用 Windows 网络路径

java - 是否可以从资源常量中声明一个字符串以在 switch 情况下使用?

java - 通过 VPN 连接到网络时,Spring Boot 应用程序不会加入 Coherence 集群

java - Appium session ,找不到连接的 Android 设备。显示错误

java - 使用 log4j2 和 mockito 断言日志消息

java - 使用 PowerMockito.whenNew() 不会被模拟并调用原始方法

java - 抽象路径在 java.io 中意味着什么?