Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Is debugging supported? #11

Closed
jonchase opened this issue Sep 18, 2011 · 8 comments
Closed

Is debugging supported? #11

jonchase opened this issue Sep 18, 2011 · 8 comments
Assignees
Milestone

Comments

@jonchase
Copy link

I typically launch a Tomcat instance for remote debugging using an Ant task like this:

    <target name="tomcat.debug">
        <java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
            <jvmarg value="-Dcatalina.home=${tomcat.home}" />
            <jvmarg value="-XX:MaxPermSize=256m" />
            <jvmarg value="-Xdebug" />
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
        </java>
    </target>

Does the Tomcat plugin support remote debugging?

Cheers,
Jon

@bmuschko
Copy link
Owner

You should be able to set the same JVM parameters on the command line when you call the Gradle task e.g.

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

In case that doesn't work let me know. My guess is that you actually want to have two tasks. One for running it normally, one for debugging. That is not supported yet and I'd have to look into. I will leave this ticket open until I have something that you can use. For now the command line parameters should work.

@ghost ghost assigned bmuschko Sep 18, 2011
@jonchase
Copy link
Author

Great point - I didn't think that through at all. Specifying those args on the command line is fine by me.

I'm not going to close the ticket since you said you'd leave it open for now. But using cmd line args works for me.

Thanks!
Jon

@bmuschko
Copy link
Owner

I added a section about remote debugging to the FAQ in the README.md.

@artemik
Copy link

artemik commented Jul 15, 2015

Command line way doesn't work:
...

  • What went wrong:
    Problem configuring task :tomcatRun from command line.

    Unknown command-line option '-X'.

@bmuschko
Copy link
Owner

@artemik Minus capital X (-X) is not a valid command line option for Gradle in general. What exactly are you referring to? If you want to set JVM parameters, you'd have to use a different notation e.g. -Dorg.gradle.jvmargs=-Xdebug. For more info see Gradle user guide.

@artemik
Copy link

artemik commented Jul 17, 2015

@bmuschko Well, but you wrote this in one line:
gradle tomcatRun -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
I'm not an expert in Gradle, that's why i came here, and this line misleads me. Anyway, the documentation says that this parameters should be set in GRADLE_OPTS which is not actually a good way for a few reasons:

  1. This won't work properly in case of several different Gradle project instances running, since they all will try to listen to the port set in GRADLE_OPTS.
  2. This won't work with turned on Gradle Daemon. Since Gradle Daemon is a new JVM instance, those properties don't apply to it. For this case there are org.gradle.jvmargs=.... If you set those jvm options via this property, it will work in both Daemon On and Daemon Off ways, because if Daemon is Off, Gradle will anyway see that you've set some properties and fork a new jvm for you (which it will notice you about), and if Daemon is On, this property (containing jvm options) will be applied to the Daemon instance.

By the way, when you use set jvm options via org.gradle.jvmargs=... you won't see Listening for transport dt_socket at address: 8000 message.

I suggest you mention these points in the documentation.

@bmuschko
Copy link
Owner

@artemik

Well, but you wrote this in one line.

I was wrong. It happens.

What you really wanted is a forked process that allows you to dedicatedly provide JVM arguments. At the moment the plugin does not provide a forked option. The embedded container runs in the same JVM as Gradle. Please see issue #58 for more details. I'd be happy to integrate a pull request. I am waiting for the community to provide it.

All other questions you have are not necessarily related to this plugin. You'd have the same issue with any other plugin that doesn't work. I'd suggest you ask those questions on the Gradle forum.

@artemik
Copy link

artemik commented Jul 20, 2015

I don't quite understand.
Why can't you specify needed jvm options in org.gradle.jvmargs? This options are applied to both the Gradle Daemon (if on) and forked jvm instance, which gradle creates if you specify any org.gradle.jvmargs with Daemon turned off. And, as per your plugin, tomcat would run inside one of these instances, depending on daemon on/off option, if you specify any org.gradle.jvmargs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants