Using JMH got : ERROR: transport error 202: connect failed: Connection refused

Viewed 53

a friendly greeting. I get a very strange problem when using JMH. Here:

ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [./src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:735]
<forked VM failed with exit code 2>
<stdout last='20 lines'>
</stdout>
<stderr last='20 lines'>
transport error 202: connect failed: Connection refused

OpenJDK 64-Bit Server VM warning: -XX:ThreadPriorityPolicy=1 may require system level permission, e.g., being the root user. If the necessary permission is not possessed, changes to priority will be silently ignored.
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [./src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:735]
</stderr>

Java version:graalvm-11 Build by Gradle:6.8.3

Gradler config:

plugins {
    id 'java'
}

group = 'com.leung.jmh'
version = '1.0'
sourceCompatibility = 11

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/org.openjdk.jmh/jmh-core
    implementation 'org.openjdk.jmh:jmh-core:1.33'
    annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.33'
}

The test code from official example :

public class Sample_helloworld {


    @Benchmark
    public void printHello ()
    {

    }

    public static void main (String[] args) throws RunnerException {
        var opt = new OptionsBuilder()
                .include(Sample_helloworld.class.getName())
                .forks(1)
                .build() ;

        new Runner(opt).run() ;
    }
}

Has anyone ever had this problem? Looking forward to your reply!

0 Answers
Related