Local debugging application launched on tomcat with cargo in IntelliJ
Asked Answered
V

2

8

I am trying to enable debugging in my cargo configuration. I'm using cargo-maven2-plugin version 1.4.19 with the following configuration.

<plugins>
  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.19</version>
    <configuration>
      <container>
        <containerId>tomcat8x</containerId>
      </container>
      <configuration>
        <type>standalone</type>
        <properties>
        <cargo.servlet.port>8080</cargo.servlet.port>
        <cargo.jvmargs>
          -Xmx2048m
          -Xms512m
          -Xdebug
          -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=63342
          -Xnoagent
          -Djava.compiler=NONE
        </cargo.jvmargs>
      </properties>
    </configuration>
    <deployer>
    </deployer>
    <deployables>
      <deployable type="war" file="target/spa.war"></deployable>
      </deployables>
    </configuration>
  </plugin>

The application launches with this configuration but IntelliJ never connects to the JVM to enable debuging. How can I make IntelliJ connect to the JVM?

Vouge answered 6/4, 2016 at 8:52 Comment(0)
V
10

I fixed this like this.

<plugins>
  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.19</version>
    <configuration>
      <container>
        <containerId>tomcat8x</containerId>
      </container>
      <configuration>
        <type>standalone</type>
        <properties>
        <cargo.servlet.port>8080</cargo.servlet.port>
        <cargo.jvmargs>
          -Xmx2048m
          -Xms512m
          -Xdebug
          -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009
          -Xnoagent
          -Djava.compiler=NONE
        </cargo.jvmargs>
      </properties>
    </configuration>
    <deployer>
    </deployer>
    <deployables>
      <deployable type="war" file="target/spa.war"></deployable>
      </deployables>
    </configuration>
  </plugin>

I used another port by changing the address like so.

-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009

I then created an IntelliJ run config for a remote by going to. Run > Edit Configurations > + > Remote I configured the remote to go to localhost and the port I had previously chosen <9009>.

enter image description here

After doing this I can start the cargo run and then start the debugger as a separate process to enable bugging.

If you want you can change the suspend argument to no like so.

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

Then the cargo build will start without running the debugger.

Vouge answered 6/4, 2016 at 11:14 Comment(1)
Have you ever been able to run this without attaching intellij as a remote process? In other words, have you ever been able to just hit run and have everything work?Roundtree
R
1

For gradle 4.3.0, under the json path cargo>local add the below param,

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

and to start the app use,

./gradlew cargoRunLocal

Rozamond answered 5/7, 2018 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.