Search code examples
javaeclipsejdi

JDI - IllegalConnectorArgumentsException: Argument invalid


I am using the JDI to debug another running java application.

What I do that works:

  1. Run two applications using Eclipse. The debugger is launched with the following VM Options:

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000
    
  2. The other application connects to the socket at port 4000, and follows normal procedures (break points, etc.) to get a value of a Local Variable.

  3. Works properly and gives me that value.

What I want to do now:

Instead of using Eclipse to launch two processes, I launch one in Eclipse, and that Process uses a ProcessBuilder to launch another one with the following arguments:

String[] args1 = {getJavaDir(),"-cp",classpath,"-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000", "processII.Main2"};
ProcessBuilder builder = new ProcessBuilder(args1);
builder.directory(directory);
Process process = builder.start();

The process starts successfully. However, when I try to access it through the first process, I get the following Error:

com.sun.jdi.connect.IllegalConnectorArgumentsException: Argument invalid

Looked this up online, and there is little information about what the Exception is.

I would appreciate any help figuring out what the problem is!


Solution

  • This exception is throw when there is an error on the connector parameters to debug the JVM. I think that your debug parameters must go in the same argument together instead of two separate arguments (put -Xdebug with -Xrunjdwp... on the same argument), try with:

    String[] args1 = {getJavaDir(),"-cp",classpath,"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000", "processII.Main2"};
    ProcessBuilder builder = new ProcessBuilder(args1);
    builder.directory(directory);
    Process process = builder.start();
    

    Hope this helps,