无法运行/调试测试,java.lang.IllegalStateException:无法初始化插件:接口org.mockito.plugins.MockMaker

kgsdhlau  于 2023-10-18  发布在  Java
关注(0)|答案(1)|浏览(289)

更新mychild POM.xml中的Junit和Mockito依赖项后,我无法运行我的Junit测试。
也有不同的版本相同的父POM,但我已经排除了他们。
我使用的依赖是-

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.9.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>5.3.1</version>
    <scope>test</scope>
</dependency>

当我试图运行或调试JUnit测试时,我得到的异常是-

"C:\Program Files\Amazon Corretto\jdk11.0.19_7\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\lib\idea_rt.jar=58070:C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\t0290551\.m2\repository\org\junit\platform\junit-platform-launcher\1.9.2\junit-platform-launcher-1.9.2.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\plugins\junit\lib\junit-rt.jar;C:\Dexxis\src\dexxisproducts\Framework\Navigator\navigator-modules-app\target\test-classes;C:\Dexxis\src\dexxisproducts\Framework\Navigator\navigator-modules-app\target\classes;C:\Dexxis\src\dexxisproducts\Framework\Core\navigator-messages\target\classes;C:\Users\t0290551\.m2\repository\com\google\gwt\gwt-user\2.8.2\gwt-user-2.8.2.jar;C:\Users\t0290551\.m2\repository\joda-time\joda-time\2.10.14\joda-time-2.10.14.jar;C:\Users\t0290551\.m2\repository\com\gemalto\dexxis\core-server-standard\P05-SNAPSHOT\core-server-standard-P05-SNAPSHOT-client.jar;C:\Dexxis\src\dexxisproducts\Server\Core\core-server-standard\target\classes;C:\Dexxis\src\dexxisproducts\Common\dexxis-core\target\classes;C:\Users\t0290551\.m2\repository\org\jboss\logmanager\jboss-logmanager\2.1.18.Final\jboss-logmanager-2.1.18.Final.jar;C:\Users\t0290551\.m2\repository\org\wildfly\common\wildfly-common\1.5.1.Final\wildfly-common-1.5.1.Final.jar;C:\Users\t0290551\.m2\repository\net\sf\jasperreports\jasperreports-fonts\4.0.0\jasperreports-fonts-4.0.0.jar;C:\Users\t0290551\.m2\repository\org\apache\commons\commons-email\1.5\commons-email-1.5.jar;C:\Users\t0290551\.m2\repository\com\sun\mail\javax.mail\1.5.6\javax.mail-1.5.6.jar;C:\Users\t0290551\.m2\repository\javax\activation\activation\1.1\activation-1.1.jar;C:\Users\t0290551\.m2\repository\org\springframework\ldap\spring-ldap-core\2.3.2.RELEASE\spring-ldap-core-2.3.2.RELEASE.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-tx\5.3.27\spring-tx-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\aspectj\aspectjtools\1.8.5\aspectjtools-1.8.5.jar;C:\Users\t0290551\.m2\repository\org\slf4j\slf4j-simple\1.7.30\slf4j-simple-1.7.30.jar;C:\Users\t0290551\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Dexxis\src\dexxisproducts\Framework\Core\dexxis-gwt-client\target\classes;C:\Users\t0290551\.m2\repository\net\lightoze\gwt-i18n-server\gwt-i18n-server\0.22\gwt-i18n-server-0.22-original.jar;C:\Users\t0290551\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Dexxis\src\dexxisproducts\Server\Core\prod-server-dto\target\classes;C:\Users\t0290551\.m2\repository\com\github\jdramaix\gwtchosen-project\1.2.0\gwtchosen-project-1.2.0.jar;C:\Dexxis\src\dexxisproducts\Framework\Core\dexxis-gwt-server\target\classes;C:\Dexxis\src\dexxisproducts\Common\dexxis-enumerations\target\classes;C:\Users\t0290551\.m2\repository\org\springframework\security\spring-security-core\5.8.3\spring-security-core-5.8.3.jar;C:\Users\t0290551\.m2\repository\org\springframework\security\spring-security-crypto\5.8.3\spring-security-crypto-5.8.3.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-aop\5.3.27\spring-aop-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-expression\5.3.27\spring-expression-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\security\spring-security-web\5.8.3\spring-security-web-5.8.3.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-beans\5.3.27\spring-beans-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-context\5.3.27\spring-context-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-core\5.3.27\spring-core-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-jcl\5.3.27\spring-jcl-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-web\5.3.27\spring-web-5.3.27.jar;C:\Users\t0290551\.m2\repository\org\springframework\spring-webmvc\5.3.27\spring-webmvc-5.3.27.jar;C:\Dexxis\src\dexxisproducts\Framework\Navigator\navigator-modules-view\target\classes;C:\Dexxis\src\dexxisproducts\Framework\Navigator\navigator-modules-api\target\classes;C:\Users\t0290551\.m2\repository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\t0290551\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Users\t0290551\.m2\repository\javax\json\javax.json-api\1.1\javax.json-api-1.1.jar;C:\Users\t0290551\.m2\repository\org\glassfish\javax.json\1.1\javax.json-1.1.jar;C:\Dexxis\src\dexxisproducts\Server\Core\prod-server-datamodel\target\classes;C:\Users\t0290551\.m2\repository\javax\xml\bind\jaxb-api\2.3.0\jaxb-api-2.3.0.jar;C:\Users\t0290551\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.9.2\junit-jupiter-engine-5.9.2.jar;C:\Users\t0290551\.m2\repository\org\junit\platform\junit-platform-engine\1.9.2\junit-platform-engine-1.9.2.jar;C:\Users\t0290551\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\t0290551\.m2\repository\org\junit\platform\junit-platform-commons\1.9.2\junit-platform-commons-1.9.2.jar;C:\Users\t0290551\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.9.2\junit-jupiter-api-5.9.2.jar;C:\Users\t0290551\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\t0290551\.m2\repository\org\mockito\mockito-core\5.3.1\mockito-core-5.3.1.jar;C:\Users\t0290551\.m2\repository\net\bytebuddy\byte-buddy\1.9.15\byte-buddy-1.9.15.jar;C:\Users\t0290551\.m2\repository\net\bytebuddy\byte-buddy-agent\1.14.4\byte-buddy-agent-1.14.4.jar;C:\Users\t0290551\.m2\repository\org\objenesis\objenesis\3.3\objenesis-3.3.jar;C:\Users\t0290551\.m2\repository\org\mockito\mockito-junit-jupiter\5.3.1\mockito-junit-jupiter-5.3.1.jar;C:\Users\t0290551\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 com.gemalto.dexxis.dexxisnavigator.security.SessionDestroyedListenerTest,testSessionDestroyed

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)

    at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:84)
    at com.sun.proxy.$Proxy16.isTypeMockable(Unknown Source)
    at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:78)
    at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
    at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:274)
    at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:235)
    at org.mockito.internal.MockitoCore.mock(MockitoCore.java:86)
    at org.mockito.Mockito.mock(Mockito.java:2101)
    at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:79)
    at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:28)
    at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:25)
    at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:44)
    at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:72)
    at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:73)
    at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:47)
    at org.mockito.MockitoAnnotations.openMocks(MockitoAnnotations.java:81)
    at org.mockito.internal.framework.DefaultMockitoSession.<init>(DefaultMockitoSession.java:43)
    at org.mockito.internal.session.DefaultMockitoSessionBuilder.startMocking(DefaultMockitoSessionBuilder.java:83)
    at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:153)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:166)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:202)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:202)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:165)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:132)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
    Suppressed: java.lang.NullPointerException
        at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:184)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$12(TestMethodTestDescriptor.java:260)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:276)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:276)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:275)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:259)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:144)
        ... 48 more
Caused by: java.lang.IllegalStateException: Internal problem occurred, please report it. Mockito is unable to load the default implementation of class that is a part of Mockito distribution. Failed to load interface org.mockito.plugins.MockMaker
    at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:104)
    at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.getDefaultPlugin(DefaultMockitoPlugins.java:78)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:75)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:50)
    at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:27)
    at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:22)
    at org.mockito.internal.MockitoCore.<clinit>(MockitoCore.java:73)
    at org.mockito.Mockito.<clinit>(Mockito.java:1683)
    at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:149)
    ... 54 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:102)
    ... 62 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException: 
It seems like you are running Mockito with an incomplete or inconsistent class path. Byte Buddy could not be loaded.

Byte Buddy is available on Maven Central as 'net.bytebuddy:byte-buddy' with the module name 'net.bytebuddy'.
For the inline mock maker, 'net.bytebuddy:byte-buddy-agent' with the module name 'net.bytebuddy.agent' is also required.
Normally, your IDE or build tool (such as Maven or Gradle) should take care of your class path completion but 
    at org.mockito.internal.exceptions.Reporter.missingByteBuddyDependency(Reporter.java:1208)
    at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:25)
    ... 67 more
Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/utility/GraalImageCode
    at org.mockito.internal.creation.bytebuddy.SubclassInjectionLoader.<init>(SubclassInjectionLoader.java:34)
    at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.<init>(SubclassBytecodeGenerator.java:75)
    at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.<init>(InlineBytecodeGenerator.java:107)
    at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.<init>(InlineDelegateByteBuddyMockMaker.java:321)
    at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:23)
    ... 67 more
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.utility.GraalImageCode
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 72 more
elcex8rz

elcex8rz1#

我喜欢的问题,我是用j-unit 5的旧版本的surefire插件,当我移动到最近的surefire插件版本。效果很好。

相关问题