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?
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
.
The second is a Remote Java Application
configuration, and will connect the debug client to the devserver jvm.
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).
You should be executing mvn from eclipse in debug mode.
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
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.
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.
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.
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).
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:
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>
mvn appengine:devserver
command from the command lineAs the title says...
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With