This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
For a user who launches an app main class from Ant normally (thus using classpath and other settings as defined by Ant), running the debugger is still a bit cumbersome: it is necessary to manually connect to the VM from NetBeans. So suggest a task loadable only inside NetBeans (provided maybe by a debuggerjpda+ant bridge mini-module?) which when executed would connect to a particular VM debugging port (and either block for the session to finish or return immediately, I don't know which is better), so a user could have: <target name="debug-in-nb"> <java fork="true" class="org.foo.MyApp"> <arg value="-Xdebug"/> <!-- whatever else JPDA needs, e.g. port opts.... --> <classpath refid="my.proj.class.path"/> </java> <nbdebug> <jpda port="1234" type="socket"/> </nbdebug> </target> Implementing such a task is pretty easy (cf. apisupport+ant module's <nbinstaller>).
The only thing to do to enable this feature is to add one more way of starting a debugger session. At the moment, a session can be started either by action "Start" (launches an application and attaches to it) or by action "Attach" (just attaches to an already running application). JPDA allows one more scenario of starting a debugging session - a debugger waits until a debugee (an application to be debugged) attaches to it. Implementation of this type of connection is the only thing that must be done in order to allow this feature.
Set target milestone to TBD
I don't believe this would need any special support from the debuggerjpda module. AFAIK you should be able to do from the Ant task: ((Debugger)Lookup.getDefault().lookup(Debugger.class)).startDebugger(new RemoteDebuggerInfo("localhost", 8888)); My previous sample build script fragment would not have worked as is, since <java> blocks for exit. However this could work: <target name="debug-in-nb"> <parallel> <java fork="true" ...> <!-- ... --> </java> <sequential> <sleep seconds="3"/> <nbdebug> <jpda port="1234" type="socket"/> </nbdebug> </sequential> </parallel> </target> The delay is of course clumsy, which I guess is what you mean by having the debugger wait until the debuggee attaches to it. But it should work most of the time - you would just need to configure the delay to be small enough to not be annoying, but large enough to work. Would be nice to also have a task which extends <java> (implicit fork="true") and (1) automatically adds appropriate JPDA VM flags, (2) does the NB attach after the process is started. This would cover typical use cases where you have a main class you want to run in the debugger. For more exotic use cases, you would launch the app however you needed to, and use the simple task to attach to it.
I have such a task written, will commit it as an experimental module soon. For now it works like Attach so you need to use <parallel>, choose a port number yourself, and put in a <sleep> to make sure the process has time to start.
See issue #37097 for the changes that would be required in the debuggerjpda module to make it nicer: <nbjpdaconnect portproperty="jpda.port"/> <java> <!-- ... --> <arg value="...,server=n,port=${jpda.port}"/> </> Then there would be no need for <parallel>, <sleep>, or guessing at a free port number. By the time <java> was run, the NB debugger would already be waiting for the Java process to connect to it on the specified port.
Should be on dev alpha Auto Update soon, so people can try it out. Checking in nbbuild/build.properties; /cvs/nbbuild/build.properties,v <-- build.properties new revision: 1.112; previous revision: 1.111 done Checking in nbbuild/build.xml; /cvs/nbbuild/build.xml,v <-- build.xml new revision: 1.373; previous revision: 1.372 done Processing log script arguments... More commits to come... RCS file: /cvs/debuggerjpda/ant/.cvsignore,v done Checking in debuggerjpda/ant/.cvsignore; /cvs/debuggerjpda/ant/.cvsignore,v <-- .cvsignore initial revision: 1.1 done RCS file: /cvs/debuggerjpda/ant/build.xml,v done Checking in debuggerjpda/ant/build.xml; /cvs/debuggerjpda/ant/build.xml,v <-- build.xml initial revision: 1.1 done RCS file: /cvs/debuggerjpda/ant/manifest.mf,v done Checking in debuggerjpda/ant/manifest.mf; /cvs/debuggerjpda/ant/manifest.mf,v <-- manifest.mf initial revision: 1.1 done Processing log script arguments... More commits to come... RCS file: /cvs/debuggerjpda/ant/src/META-INF/taskdefs.properties,v done Checking in debuggerjpda/ant/src/META-INF/taskdefs.properties; /cvs/debuggerjpda/ant/src/META-INF/taskdefs.properties,v <-- taskdefs.properties initial revision: 1.1 done Processing log script arguments... More commits to come... RCS file: /cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/Bundle.properties,v done Checking in debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/Bundle.properties; /cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/Bundle.properties,v <-- Bundle.properties initial revision: 1.1 done RCS file: /cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/JPDAConnect.java,v done Checking in debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/JPDAConnect.java; /cvs/debuggerjpda/ant/src/org/netbeans/modules/debugger/jpda/ant/JPDAConnect.java,v <-- JPDAConnect.java initial revision: 1.1 done
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.