31

I am in the process of switching from Google Plugin for Eclipse to the official Google App Engine Maven Plugin. The last thing, I hope, that I cannot figure out is how to get a good debug workflow set up. When I was using GPE, I just set breakpoints and the debugger stopped there automagically, but when I run the dev server via mvn appengine:devserver, I don't think the dev server and eclipse are aware of each other.

How do I make them talk to each other?

3

6 Answers 6

46

The first option is to set up your project to use WTP as documented @ https://cloud.google.com/appengine/docs/java/webtoolsplatform. This is the method I switched to.

The second option is to use two debug configurations.

The first debug configuration will run your maven target, namely appengine:devserver. enter image description here

The second is a Remote Java Application configuration, and will connect the debug client to the devserver jvm.
enter image description here

This also requires some jvm args to be passed to the maven goal.

<!-- GAE plugin -->
<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.7.5-SNAPSHOT</version>
    <configuration>
        <jvmFlags>
            <jvmFlag>-Xdebug</jvmFlag>
            <jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y
            </jvmFlag>
        </jvmFlags>
        <disableUpdateCheck>true</disableUpdateCheck>
    </configuration>
</plugin>

Once those 3 things are in place, run the maven debug configuration, then run the debug client configuration, then exercise your application.

There is no support for hotswap yet, so if you change any non-resource files(any java source), the devserver will not see them. Resource files will get deployed(static files: html, js).

6
  • Thanks for sharing that (and pushing for the plugin update). What do the "wait" and "disableUpdateCheck" serve for?
    – H-H
    Jan 4, 2013 at 20:39
  • disableupdatecheck stops the plugin from asking google if there is a new version of the sdk. wait doesn't do anything. Jan 5, 2013 at 18:45
  • you need to be using the snapshot version of the plugin for this to work. Jan 7, 2013 at 15:34
  • 5
    Hi. This approach works but it is somewhat cumbersome as you have to start to launch configs from within eclipse. Also when changing something in the server code you won't be warned to restart the server. Isn't there a way to simply start the mvn appengine:devserver goal in debug mode?
    – Moritz
    Jan 19, 2013 at 11:16
  • Also when using the two launch configs approach... the mvn launch configs starts two jvms where only one is terminated when i kill the running appengine so i always have a stale java process running.
    – Moritz
    Jan 19, 2013 at 11:41
1

You should be executing mvn from eclipse in debug mode.

enter image description here

In Eclipse you can configure such maven build commands from eclipse top toolbar "Run" -> "Debug Configuration" -> "Maven Build"

Once in maven is launched in eclipse debug mode you should be able to hit the breakpoints.

Edit - One other option is to set up Remote Debug i.e "Run" -> "Debug Configuration" -> "Remote Java Application" and listen remote debug port i.e You should ensure appengine:devserver launches with remote debug port arguments - Reference - Remote Debugging in eclipse

2
  • 2
    Using a goal of appengine:devserver, that doesn't seem to make a difference. I do not see output in the eclipse console, nor are the breakpoints being hit. The devserver does indeed start, and the app functions as expected, but no debugging. Dec 18, 2012 at 4:22
  • 1
    I think the webapp is running in a new thread that eclipse is not watching/listening. Dec 18, 2012 at 4:29
1

This question may give you a hint of the problem. The Maven appengine:devserver starts the development server on a separate process. Eclipse however is only aware of the Maven process itself (this is what you see in the debug view). In addition, since the dev server cannot be started with arguments such as a debug port, it probably can never be connected to a debugger.

The question linked suggest that there's an unofficial Maven GAE plugin which takes arguments. There's also a new ticket to enhance the official plugin and a promise by the plugin developper to implement this feature soon.

2
1

I'll see what else I can do to make the eclipse integration easier, but there is now an update to the issue filed to the appengine-maven-plugin project : http://code.google.com/p/appengine-maven-plugin/issues/detail?id=3&can=1 so take a look and see if the support for the jvm arguments can help you out.

Please let me know your experiences, I'm always in favor of things being awesome.

4
1

Answer Relevant in 2015

I created a GAE (Java) project in Sep 2015 and the following applies to this and similar projects.

I started by creating my project as on ordinary GAE maven project using the Skeleton archetype by simply following the relevant steps from Using Apache Maven - Java — Google Cloud Platform. Followed through from Requirements through to Testing your app with the development server.

After that I imported this project into Eclipse JEE (Mars) using "Import an existing Maven project". Started development.

When I needed to debug, I only had to carry out the few steps explained below.

Create a debug configuration

Go to Run -> Debug Configurations, click on Remote Java Application and create a new configuration by clicking on the New button (see screenshot, upper left corner above filter text box).

Create a new debug configuration for Remote Java Application

Fill in the details by choosing your particular project and giving a suitable name to the configuration as shown below (let port be 8000) and click Apply:

Settings for the debug configuration

Uncomment some lines in pom.xml

In your project's pom.xml, find the configuration for plugin appengine-maven-plugin and uncomment the following lines:

                <jvmFlags>
                    <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
                </jvmFlags>

Run the mvn appengine:devserver command from the command line

As the title says...

Attach the debugger from within Eclipse

Click on the little down-triangle next to the button for Debug and choose the name of the debug configuration you just set up ("HelloWorldServlet" in my example).

0

I roughly follow the steps @ developers.google.com/appengine/docs/java/webtoolsplatform in favor of my previous method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.