简体   繁体   中英

Remote Debug Tomcat 7 With IntelliJ

I have a web application running on 10.0.1.62:8080/xxx . I want to debug remotely via IntelliJ IDEA. I have set JAVA_OPTS = -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

on 10.0.1.62 machine(Tomcat7 on Ubuntu) and when I hit the remote debug button IDE is giving an info message :

Connected to the target VM, address: '10.0.1.62:8000', transport: 'socket'

Than I am hitting the 10.0.1.62:8080/xxx . Although I get this success message brekpoints are not hit. What am I missing ?

Firstly, double check your settings by referencing this question and answer: Remote Debugging in IntelliJ Tomcat

From you question it sounds like you have already followed these steps. There are a few other config problems that have caused me issues with remote tomcat debugging in the past that I'll share and hope it helps.

  1. Be sure you started the proper remote debugging process on IntelliJ. 远程调试
  2. Make sure you are connecting to the correct Tomcat instance, if there are multiple Tomcat servers running on your host. The debug port 8000 may already be in use. I'm use an arbitrary port of 15019 or some other port number not already in use. Make sure the ports used match between Tomcat and IntelliJ.
  3. Depending on how you setup remote debugging on Tomcat, it may not shutdown properly leaving an old instance running. Adding the debug hooks at the top of catalina.sh will cause the shutdown.sh script to fail because your debug port is already bound to the Tomcat server. Instead place it within the start if statement:

    elif [ "$1" = "start" ] ; then JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=15019,suspend=n,server=y"

After fixing this issue, you can shutdown Tomcat successfully with ./shutdown.sh and still start debugging with ./startup.sh

  1. Make sure you have a clean deployment of your application on Tomcat. Your cleanup process may require variations, but here is the general idea:

    Shutdown Tomcat, then verify it is no longer running. Remove the deployed war file and corresponding exploded version from your tomcat webapps directory. Remove the contents of the work and temp directories. Deploy and verify your recently build war file. Start Tomcat.

Creating a script to do this will save time.

  1. If all else fails, add a debug log to double check the code with the breakpoint is being invoked in the first place.

I'm sure there are twenty other things that could go wrong. Feel free to add ideas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM