Remote Debugging in IntelliJ Tomcat

2019-01-31 06:44发布

How to enable remote debugging from IntelliJ with Tomcat?

7条回答
叼着烟拽天下
2楼-- · 2019-01-31 07:01

Add these two line to your bin/setenv.sh

export JPDA_ADDRESS="5005"
export JPDA_TRANSPORT="dt_socket"

Add remote Run/Debug Configuration in IntelliJ IDEA. (see the answer from @Jonathan L). You can keep the default port '5005'.

Start tomcat,

catalina.sh jpda run

Then simply run debug on the IDE.

查看更多
Summer. ? 凉城
3楼-- · 2019-01-31 07:08

you can set

export CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"

in setenv.sh file in bin tomcat directory (remote server) and restart it.

then just you should add Remote in Run/Debug Configurations in intellij and set Host to remote server and Port 8000

查看更多
forever°为你锁心
4楼-- · 2019-01-31 07:10

Remote debugging of web applications running in Tomcat 7 is extremly convenient in IntelliJ IDEA 12 if you use Maven!

Just configure your pom-file to use the tomcat7-maven-plugin, eg:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
</plugin>

Then use the "Maven Projects" tool window to start the tomcat7:run goal in debug mode (see screenshot).

enter image description here

查看更多
冷血范
5楼-- · 2019-01-31 07:12

Use Tomcat Run/Debug Configuration. Click the enter image description here button and choose new Remote configuration. In the Configuration tab copy the JVM options suggested by IDEA.

Run Tomcat with the suggested JVM options:

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1317,suspend=n,server=y
startup

Press Debug button in IDEA.

Otherwise it's the same as for Local Tomcat, check the tutorial.

Note that deploying to Tomcat is available only in IDEA Ultimate, but you can still manually deploy to Tomcat on your own and use Java's remote debug features using the free edition.

查看更多
聊天终结者
6楼-- · 2019-01-31 07:12

Assume you start Tomcat standalone and attach debugger remotely to it from IntelliJ IDE.

1) Start Tomcat in debug mode
   $TOMCAT_HOME/bin/catalina.sh jpda start

   By default JPDA_ADDRESS is defined as "localhost:8000" in catalina.sh
   Change to a different port as need

2) In IntelliJ IDE
   Click Run > Edit Configurations
   Click + icon on the top-left toolbar
   Click Remote
   Enter a name you want in Name input box
   Enter 8000 in Port input box under Settings section

3) Click Apply, then OK
4) Run > Debug..., Click the configuration you just created

Note:

1) This should work with other remote JPDA instances such as WebLogic, JBoss, etc.
2) Documentation environment: Linux, IntelliJ IDEA 15.0.2

IntelliJ Remote Debugger Configuration

查看更多
来,给爷笑一个
7楼-- · 2019-01-31 07:17

In Intellij Idea:

  1. Click on Run -> Edit Configurations -> Add New Configurations ("+" icon)

  2. Click on Remote

  3. Set Host and Port

  4. Copy content of Command line arguments for running remote JVM, for example:

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

enter image description here

If you use Tomcat Service (for Tomcat 9):

  1. Go to %TOMCAT_INSTALL_DIR%/bin

  2. Run tomcat9w.exe

  3. Click on Java tab

  4. In Java Options Paste the copied text:

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

  5. Apply.

enter image description here

查看更多
登录 后发表回答