Tomcat within Eclipse - starting with JPDA enabled

13.8k views Asked by At

I'm trying to get a webapp up and running - for debugging - within a Tomcat instance configured in Eclipse (to keep my work flow as automatic as possible). I'm trying to get remote debugging enabled within the Tomcat JVM, and I've read about two sets of VM arguments:

-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n

or..

-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

But whenever I attempt to use either of these, I get an error message in my console:

Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.

I don't know where I should be looking for these other - supposedly duplicate - jdwp options. Where are these configured? How can I get this working?

1

There are 1 answers

4
Kris Babic On BEST ANSWER

If you've correctly setup Tomcat to be started and stopped inside an Eclipse instance, then you should not have to manually setup the debug options for the server to debug your application from inside of Eclipse. When you start Tomcat in debug mode from within Eclipse, the debug options are automatically added to the startup process. By manually configuring them in the launch configuration you are causing a duplication of the settings, thus the error response.

To verify that you have setup the server correctly, here are some steps to setup Tomcat in the Helios release:

  • If your Servers view is not open, go to Window->Show View->Servers
  • Right-click the servers window and select New->Server
  • In the 'Select the server type' window select the Tomcat version you are setting up
  • Select next (if already configured the server runtime environment, then 'Finish' button will be available)
  • Enter server name and installation directory for your environment
  • select 'Finish'

At this point, you should be able to see your newly setup Tomcat instance in your Servers window. At this point you can deploy your application to the newly setup server. To start the server in debug mode, you can select the debug botton available from the Servers window. Once the server starts the IDE will be automatically connected to allow for debugging your deployed application.