5

I'm converting some backends to modules and am perplexed on setting up the development environment configuration. I'm using Java in Eclipse but not Maven. The architecture is very simple:

  • Front end module is default. Basic GAE/GWT app. Puts items on task queue.
  • Back end module processes task queue.

With the old backend architecture one debug configuration would start up the development server that would service the GWT DevMode UI and the backend task processing.

The crux of the issue is that the arguments to DevMode provide for a -war command line argument. Now that we no longer have a single war file (there is an ear containing two war files), we have to start them independently. This is fine, we can create a Launch Group that starts up the frontend and backend.

The problem is that each war file gets it's own WEB-INF/appengine-generated/local_db.bin, which essentially creates two standalone applications. Am I missing something here? I need to be able to put a breakpoint on my front-end RPC service and in the servlet that handles task queue items in the new backend and have both of them hit in one debugging session.

Thanks for any thoughts.

Thomas W.
  • 130
  • 9
Dominic Tracey
  • 767
  • 6
  • 14

2 Answers2

3

If you follow the instructions here, this will create a modularized application structure in Eclipse, and not using Maven at all. You will need Eclipse WTP in order to have the required project types available (Enterprise Application Project and Dynamic Web Project).

The Eclipse project structure should look as follows:

<<Enterprise Application Project>> ear-app
    |
    | (refers to)
    |
<<Dynamic Web Project>> app-module-1  "default"
<<Dynamic Web Project>> app-module-2  "any_name_2"
<<Dynamic Web Project>> app-module-3  "any_name_3"
<<Dynamic Web Project>> app-module-4  "any_name_4"

The value of "name" refers to the "module" element in appengine-web.xml, while the physical web project can have any name.

Please note that you need to switch into J2EE perspective in order to have the GPE WTP menu options available, they do not show up in the standard Java perspective.

Next, you need to link the EAR project to a new local server instance (of type "Google App Engine").

Only one of the web modules must be flagged as "default" in appengine-web.xml.

Upon deployment of the EAR to the local server, the datastore location is in WEB-INF/appengine-generated/local_db.bin of the default web module, and it is shared between the web modules.

Thomas W.
  • 130
  • 9
  • I'm going to accept this - I haven't fully confirmed it yet because I came up with a workaround for my rather sprawling set of applications. This (or the maven archetypes) would definitely be the way to go in a green field scenario. Thanks everyone! – Dominic Tracey May 12 '14 at 21:26
  • How can I specify port number for second module? First can be configured in pom.xml but I don't see a way to set it for second module. – Gapipro Jun 10 '14 at 06:10
  • Gapipro, you cannot specify the port numbers of the other modules in the development server. This seems to be an artificial restriction by Google. For testing, I help myself with iptables port redirection for the API I want to test (each time I re-start the dev server). Cumbersome, but this way I do not need to reconfigure the Android app (or any other client). – Thomas W. Jun 11 '14 at 07:47
  • The datastore on my development server is put in `...\Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\my-ear\my-default.war\WEB-INF\appengine-generated\local_db.bin`. Is it possible to get it into the WEB-INF/appengine-generated/local_db.bin of the default web module, as suggested by Thomas W.? – rakensi Jan 14 '16 at 14:10
2

I'm having similar problems figuring out how to implement multiple modules in the MyEclipse plugin for Google App Engine. The best information I've found just says to use Maven.

"Although Java EE supports WAR files, module configuration uses unpacked WAR directories only. App Engine's Java SDK includes an Apache Maven tool that can build a skeletal EAR structure for you." (source: https://developers.google.com/appengine/docs/java/modules/)

I also found this:

"A Maven project has a different layout than an Eclipse project. So, if you wish to use a Maven project with Eclipse, you need to do a bit more work. You have the following options:

1] Import a Maven project for App Engine into Eclipse as a Web Tools Platform (WTP) project, as described in Importing an Existing Maven Project.

2] Import the Maven project into Eclipse using an appropriate Maven integration plugin such as m2eclipse.

3] Set up two debug configurations, one for the Maven project in devserver (mvn appengine:devserver), and one for a Remote Java Application that you use to connect the Eclipse debug client to the devserver jvm. For details on how to do this, see ..." (source: https://developers.google.com/appengine/docs/java/tools/maven#creating_a_new_maven_app_engine_project_using_skeleton-archetype)

I know you said you're not using Maven, but might you consider trying it?

Michael Osofsky
  • 11,429
  • 16
  • 68
  • 113
  • I searched "Google AppEngine adding modules wihout maven" and found this comment http://stackoverflow.com/questions/22732977/google-appengine-adding-modules-wihout-maven#comment34674194_22732977 which seems promising. – Michael Osofsky Apr 11 '14 at 23:58
  • Thanks for this. I haven't used Maven before and gave it an honest go (using M2E to import the project created by the google archetypes). I decided to try to move forward without it for a few reasons: 1) I still suspect my problem (debugging two server-side modules) is still there 2) the performance in Eclipse of the sample apps left me concerned about the scaling and 3) the project structure produced by the archetype is so different from what I have for my current workspace that it will be a significant effort just to migrate. Hence the search for the middle ground. – Dominic Tracey Apr 13 '14 at 15:40
  • And to be clear, I can add modules without Maven and deploy working versions onto the Google infrastructure. My specific problem is getting two modules to share the same local_db.bin in my development environment. If someone can confirm that using Maven/M2E will allow for multiple modules to share a local_db.bin I will push down that path further. – Dominic Tracey Apr 13 '14 at 15:48
  • Aquilon, congrats on getting at least to that point. I can't find instructions for creating multiple modules without Maven. But if I get as far as you I will have to resolve the same problem: I want my modules to share a single datastore. If you can get me up to speed on multiple modules, I'd be glad to help solve the single datastore problem. – Michael Osofsky Apr 15 '14 at 00:04
  • Aquilon, I've been reading Google App Engine documentation all day and I'm pretty sure now that modules should be able to share the same datastore. – Michael Osofsky Apr 16 '14 at 23:40
  • I think this will also help you: "When you run the development server and exercise your app, indexes required for operation in production App Engine are automatically generated in guestbook/guestbook-ear/target/guestbook-ear-1.0-SNAPSHOT/guestbook-war-1.0-SNAPSHOT.war/WEB-INF/appengine-generated/datastore-indexes-auto.xml . You'll also notice the file local_db.binat that same location: this is local storage for the development server to persist your app data between development server sessions." source: https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore – Michael Osofsky Apr 16 '14 at 23:41
  • Hey sorry for the late reply, crazy busy on another project. So the example guestbook app doesn't have modules I don't think. The local_db.bin is created in the war folder of the default module. For it to work, it would seem like it would need to be at the ear level, not one of its component wars. – Dominic Tracey Apr 17 '14 at 16:31
  • Hi Aquilon, my saga continues. I've posted a new question at http://stackoverflow.com/questions/23141302/possible-to-use-google-modules-with-google-plugin-for-eclipse. If I get that answered it might address your question. Might. – Michael Osofsky Apr 17 '14 at 19:59
  • Ok - I can confirm the answer derived in your question here: http://stackoverflow.com/questions/23141302/possible-to-use-google-modules-with-google-plugin-for-eclipse gets you to a point where you have a development environment in which multiple modules share the same local_db.bin. Thanks! – Dominic Tracey Apr 20 '14 at 17:13