Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails with "Can not attach to current VM" #24

Open
vinith opened this issue Jul 1, 2023 · 1 comment
Open

Fails with "Can not attach to current VM" #24

vinith opened this issue Jul 1, 2023 · 1 comment
Labels

Comments

@vinith
Copy link

vinith commented Jul 1, 2023

Added the below to build.gradle.kts (Note that without this change the same set of commands below do work, so this is indicative of a problem that adding the below dependency is the reason and that the rest of the project and setup are functional)

implementation("org.walkmod:junit5git:1.3")

ran gradle check

The tests are not run and it fails with

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 1.
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
	at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at [email protected]/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider org.walkmod.junit4git.junit5.Junit5GitListener could not be instantiated
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.junit.platform.launcher.core.LauncherFactory.registerTestExecutionListeners(LauncherFactory.java:179)
	at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:137)
	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:125)
	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:109)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:97)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
	... 18 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at com.ea.agentloader.AgentLoader$1.loadAgent(AgentLoader.java:244)
	at com.ea.agentloader.AgentLoader.loadAgent(AgentLoader.java:77)
	at com.ea.agentloader.AgentLoader.loadAgentClass(AgentLoader.java:148)
	at com.ea.agentloader.AgentLoader.loadAgentClass(AgentLoader.java:102)
	at org.walkmod.junit4git.core.TestsReportClient.startUpAgentServer(TestsReportClient.java:43)
	at org.walkmod.junit4git.core.TestsReportClient.<init>(TestsReportClient.java:37)
	at org.walkmod.junit4git.core.TestsReportClient.<init>(TestsReportClient.java:31)
	at org.walkmod.junit4git.junit5.Junit5GitListener.<init>(Junit5GitListener.java:19)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
	... 36 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.ea.agentloader.AgentLoader$1.loadAgent(AgentLoader.java:240)
	... 49 more
Caused by: java.lang.RuntimeException: java.io.IOException: Can not attach to current VM
	at com.ea.agentloader.AgentLoaderHotSpot.getVirtualMachine(AgentLoaderHotSpot.java:90)
	at com.ea.agentloader.AgentLoaderHotSpot.loadAgent(AgentLoaderHotSpot.java:56)
	... 54 more
Caused by: java.io.IOException: Can not attach to current VM
	at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:76)
	at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:56)
	at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
	at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
	at com.ea.agentloader.AgentLoaderHotSpot.getVirtualMachine(AgentLoaderHotSpot.java:86)
	... 55 more
	
@vinith
Copy link
Author

vinith commented Jul 1, 2023

I had to make the following changes to get the project to build

     baseName = 'junit4git-agent'
+    duplicatesStrategy = 'INCLUDE'
     from {
-        configurations.compile.collect { it.isDirectory() ? it : zipTree(it)}
+        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it)}

and then when I run
./gradlew build customFatJar

I get the same exception

Caused by: java.io.IOException: Can not attach to current VM

even on the sample project provided

Task :junit5-sample:junitPlatformTest FAILED
Exception in thread "main" java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider org.walkmod.junit4git.junit5.Junit5GitListener could not be instantiated
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
        at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
        at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.junit.platform.launcher.core.LauncherFactory.registerTestExecutionListeners(LauncherFactory.java:179)
        at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:137)
        at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:125)
        at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:109)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:61)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
        at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
        at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
        at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:84)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:74)
        at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:47)
        at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:39)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.ea.agentloader.AgentLoader$1.loadAgent(AgentLoader.java:244)
        at com.ea.agentloader.AgentLoader.loadAgent(AgentLoader.java:77)
        at com.ea.agentloader.AgentLoader.loadAgentClass(AgentLoader.java:148)
        at com.ea.agentloader.AgentLoader.loadAgentClass(AgentLoader.java:102)
        at org.walkmod.junit4git.core.TestsReportClient.startUpAgentServer(TestsReportClient.java:51)
        at org.walkmod.junit4git.core.TestsReportClient.<init>(TestsReportClient.java:41)
        at org.walkmod.junit4git.core.TestsReportClient.<init>(TestsReportClient.java:35)
        at org.walkmod.junit4git.core.TestsReportClient.<init>(TestsReportClient.java:31)
        at org.walkmod.junit4git.junit5.Junit5GitListener.<init>(Junit5GitListener.java:19)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
        ... 22 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at com.ea.agentloader.AgentLoader$1.loadAgent(AgentLoader.java:240)
        ... 36 more
Caused by: java.lang.RuntimeException: java.io.IOException: Can not attach to current VM
        at com.ea.agentloader.AgentLoaderHotSpot.getVirtualMachine(AgentLoaderHotSpot.java:90)
        at com.ea.agentloader.AgentLoaderHotSpot.loadAgent(AgentLoaderHotSpot.java:56)
        ... 41 more
Caused by: java.io.IOException: Can not attach to current VM
        at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:76)
        at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:56)
        at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
        at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
        at com.ea.agentloader.AgentLoaderHotSpot.getVirtualMachine(AgentLoaderHotSpot.java:86)
        ... 42 more

FAILURE: Build failed with an exception.

@rpau rpau added the bug label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants