Database Reference
In-Depth Information
To enable JDWP, where your Java application offers a JDWP server, pass the follow‐
ing options to the JVM when you start your Java application:
-agentlib:jdwp=transport=dt_socket,server=y,suspend= n ,address= 127.0.0.1:4000
To enable JDWP, where your Java application connects using JDWP to a debugger,
pass the following options to the JVM when you start your Java application:
-agentlib:jdwp=transport=dt_socket,server=n,suspend= y ,address= 127.0.0.1:4005
The suspend parameter may be set to either y or n . When set to y (yes), it will cause
your Java application not to start running within the JVM immediately, but to wait
until a debugger connects to the application in server mode, or the Java application
connects to the debugger in client mode. This can be very useful with applications
like eXist where you may wish to debug the database startup process.
The address parameter will cause the JVM to listen on a specific IP address and TCP
port for JDWP requests in server mode, or to connect to a debugger listening on that
specific address and port in client mode. If you use the localhost address of
127.0.0.1 , then the debugger must be running on the same machine. If you wish to
debug across the network, you need to specify the IP address of the server's network
interface in server mode (or you can omit the IP address entirely to listen on all
server addresses), or the client's IP address in client mode.
We have discussed the JDWP settings in the context of any Java application, as eXist
can be set up to run in many different ways, and you may need to add these options
to whichever mechanism you are using to start eXist on your local machine or server.
For further details, see http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/
conninv.html#Invocation . However, if you are using the $EXIST_HOME/client.sh
and/or $EXIST_HOME/startup.sh scripts to start eXist, then you can simply uncom‐
ment the line that starts DEBUG_OPTS near the top of those files to have JDWP enabled
in server mode. Remember that you will have to restart eXist for these changes to
take effect.
Remote debugging with the NetBeans IDE
While any IDE or client that supports JDWP can be used as a debugger against the
Java code that makes up eXist, here we show how you can use the NetBeans IDE to
connect to eXist running as a JDWP server. Before continuing you must start eXist
running as a JDWP server, as discussed earlier.
eXist ships with project files for NetBeans, so you can simply go to the File→Open
Project menu item in NetBeans and select your $EXIST_HOME folder. Once the
project has loaded, you need to attach the NetBeans debugger to the eXist JDWP
server by choosing the Debug→Attach Debugger menu item (see Figure 16-7 ).
Search WWH ::




Custom Search