[Bug]: Unable to attach to a JVM #519

Closed
@miroslavvojtus

Description

Has this been reported before?

  • I have checked for existing reports of this issue
  • Repro steps

    I tried both runing from terminal and attaching via attach to JVM.

    The target application is running Java 17
    JDKs tried: corretto-17.0.9, temurin-17.0.9

    I have started HTTPToolkit from terminal where JAVA_HOME is set to one of above JDKs.

    How often does this bug happen?

    Every time

    The desktop OS you're using

    Widnwos 10

    Details of other apps/devices

  • intercepting Java 17
  • running with Java 17
  • Error screenshot

    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AgentLoadException
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
            at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
            at java.lang.Class.getMethod0(Class.java:3018)
            at java.lang.Class.getMethod(Class.java:1784)
            at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:670)
            at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:652)
    Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AgentLoadException
            at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
            ... 7 more
    Error: Failed to attach to JVM, exit code 1
        at e.JvmInterceptor.activate (C:\Users\z003rt0k\AppData\Local\Programs\httptoolkit\resources\httptoolkit-server\bundle\index.js:944:82478)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async e.ApiModel.activateInterceptor (C:\Users\z003rt0k\AppData\Local\Programs\httptoolkit\resources\httptoolkit-server\bundle\index.js:890:742102)
        at async C:\Users\z003rt0k\AppData\Local\Programs\httptoolkit\resources\httptoolkit-server\bundle\index.js:944:3509
        at async C:\Users\z003rt0k\AppData\Local\Programs\httptoolkit\resources\httptoolkit-server\bundle\index.js:944:2198
    [17380:1114/095738.973:ERROR:display_layout.cc(551)] PlacementList must be sorted by first 8 bits of display_id 
    

    Any other info?

    No response