'Tests do not start when using JProfiler plugin in Gradle
I have a Gradle project with unit tests. If I do
./gradlew tests
the tests run as expected. One of them is very slow, so I was attempting to profile it with JProfiler. Based on https://www.ej-technologies.com/resources/jprofiler/help/doc/commandLine/gradleTasks.html, I added this to my build.gradle.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.jprofiler:gradle_publish:13.0-PRE1"
}
}
apply plugin: "com.jprofiler"
<pre-existing build file>
jprofiler {
installDir = file('/Applications/JProfiler.app/Contents/Resources/app')
}
task testProfile(type: com.jprofiler.gradle.TestProfile) {
// mainClass = 'com.mycorp.MyMainClass'
//classpath sourceSets.main.testClasspath
// offline = true
// sessionId = 80
// configFile = file('path/to/jprofiler_config.xml')
}
Now if I do ./gradlew tasks, it lists the testProfile task. When I try to run the task, it waits for the profiler to connect.
$ ./gradlew testProfile
> Task :testProfile
JProfiler> Protocol version 55
JProfiler> Using JVMTI
JProfiler> Java 9+ detected.
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jprofiler.agent.LockManager to field java.util.concurrent.locks.AbstractOwnableSynchronizer.exclusiveOwnerThread
WARNING: Please consider reporting this to the maintainers of com.jprofiler.agent.LockManager
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
JProfiler> Retransforming 249 base class files.
JProfiler> Base classes instrumented.
JProfiler> Waiting for a connection from the JProfiler GUI ...
<===========--> 85% EXECUTING [53s]
> :testProfile > 0 tests completed
In JProfiler, I open Start Center and in the Quick Attach tab, I see to gradle related processes.
I select the one with testProfile, and get an error about numeric values.
In the gradle window, there are messages that look like JProfiler starting up.
<===========--> 85% EXECUTING [2m 32s]
> :testProfile > 0 tests completed
JProfiler> Protocol version 55
JProfiler> Using JVMTI
JProfiler> Java 9+ detected.
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Listening on port: 51641.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jprofiler.agent.LockManager to field java.util.concurrent.locks.AbstractOwnableSynchronizer.exclusiveOwnerThread
WARNING: Please consider reporting this to the maintainers of com.jprofiler.agent.LockManager
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Retransforming 9 base class files.
JProfiler> Attach mode initializedzed
<===========--> 85% EXECUTING [3m 41s]
> :testProfile > 0 tests completed
When I reopen Start Center, the process is now highlighted in green.
I select it, and now JProfiler appears to connect. I can see all the types of information I expect to see about the process.
However, it appears to just be Gradle control processes.
In the gradle window, I do not see any indication that the tests are running. All I see is, every 2 minutes, a message about a timeout and (I think) a restart.
JProfiler> Using sampling (5 ms)
Unable to connect to the child process 'Gradle Test Executor 12'.
It is likely that the child process have crashed - please find the stack trace in the build log.
This exception might occur when the build machine is extremely loaded.
The connection attempt hit a timeout after 120.0 seconds (last known process state: STARTED, running: true).
org.gradle.process.internal.ExecException: Unable to connect to the child process 'Gradle Test Executor 12'.
It is likely that the child process have crashed - please find the stack trace in the build log.
This exception might occur when the build machine is extremely loaded.
The connection attempt hit a timeout after 120.0 seconds (last known process state: STARTED, running: true).
at org.gradle.process.internal.worker.DefaultWorkerProcess.doStart(DefaultWorkerProcess.java:192)
at org.gradle.process.internal.worker.DefaultWorkerProcess.start(DefaultWorkerProcess.java:168)
at org.gradle.process.internal.worker.DefaultWorkerProcessBuilder$MemoryRequestingWorkerProcess.start(DefaultWorkerProcessBuilder.java:252)
at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.forkProcess(ForkingTestClassProcessor.java:118)
at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.processTestClass(ForkingTestClassProcessor.java:91)
at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.processTestClass(RestartEveryNTestClassProcessor.java:52)
at jdk.internal.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
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.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:30)
at org.gradle.internal.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:87)
at org.gradle.internal.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:36)
at org.gradle.internal.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:71)
at org.gradle.internal.concurrent.InterruptibleRunnable.run(InterruptibleRunnable.java:42)
at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
JProfiler> Protocol version 55
JProfiler> Using JVMTI
JProfiler> Java 9+ detected.
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
I have also tried connecting to the other gradle process, but it has similar results.
What do I need to do to get the tests to actually run?
Config:
JProfiler 9.2.1
$ ./gradlew --version
Gradle 6.4.1
Build time: 2020-05-15 19:43:40 UTC Revision: 1a04183c502614b5c80e33d603074e0b4a2777c5
Kotlin: 1.3.71 Groovy: 2.5.10 Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019 JVM: 11.0.8 (AdoptOpenJDK 11.0.8+10) OS: Mac OS X 10.16 x86_64
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|




