Help me in making the integration of GAE, Eclipse and Maven smoother and star this issue in AppEngine
Update: This solution doesn’t work on Eclipse 3.6 Helios and newest version of m2eclipse, check out the new solution if you’re on the latest version.
Nowadays everybody wants to manage their Java projects with Maven. And that’s totally sensible since Maven makes some things pretty damn easy, mostly because there’s a plugin for about everything. Yes, there is a plugin for Google App Engine (GAE) too, with which you can run the local development server and deploy your app. The same features are available on the Google Plugin for Eclipse, which is the Google preferred way to develop Java-based App Engine applications. So of course you’d like to also utilize the IDE integration, especially when the startup time of the local GAE development server is significally faster, thus increasing your productivity. So far, the problem has been, how to enjoy the benefits of both worlds, and I’ve have to tell you, it is now solved. Another thing I have to tell you is, how, so here we go.
Requirements
- Google App Engine SDK for Java 1.3.0
- Eclipse == 3.5 (with Java Development Tools)
- Maven >= 2.0.9
- Google Plugin for Eclipse (link to the update site)
- m2eclipse (link to the update site)
The integration isn’t compatible with m2eclipse, but it’s required for attaching the Maven war:exploded goal to Eclipse compilation. Also the integration is not perfectly production ready since it has to rely on snapshot version of maven-eclipse-plugin hosted at Bearded Geeks’ Maven repository. It’s required for linkedResource configuration and using the Eclipse Java Compiler. For more details see plugin’s issue tracker for linkedResources and output classes (Voting the issue and by other means trying to get the patches in highly appreciated).
So, I’ve converted the Guestbook Example into a Maven managed one and I’m distributing it as a Maven archetype. So, here’s how you begin:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate \ -DarchetypeGroupId=org.beardedgeeks \ -DarchetypeArtifactId=gae-eclipse-maven-archetype \ -DarchetypeVersion=1.1.2 \ -DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/releases
By running that command you can create a Maven managed GAE app of your own. Just remember to change everything to match your application, like appId etc. To enable Eclipse integration run mvn eclipse:eclipse. After that you’ll need to import the project to Eclipse and after that and few project refreshs you should be fine (don’t mind it giving warnings about some missing libraries, they shouldn’t affect). Just run it as you usually run App Engine projects in Eclipse. Also on every Eclipse startup the Eclipse might put its GAE libraries back to war/WEB-INF/lib which’ll cause failure on startup, but cleaning the project solves the problem. You can also run your project using maven-gae-plugin by typing mvn gae:run on command line or deploy to App Engine by typing mvn gae:deploy.
If you’re not that into archetypes, you can find the project sources through SVN at Bearded Geeks’ Google Code project. The guestbook example can be found up and running at the project’s GAE page.
Trying to follow this (bit of a maven newbie). Not sure what you mean by:
> The integration isn’t compatible with m2eclipse, but it’s required for attaching the Maven war:exploded goal to Eclipse compilation.
I installed the m2eclipse plugin (running gallileo) and cannot get around clean/build errors:
Launch configuration type id “org.maven.ide.eclipse.Maven2BuilderConfigurationType” does not exist.
Possible causes:
Missing specification of a launch type (missing plug-in)
Incorrect launch configuration XML
Can’t find any clue on internet.
I think it means that the m2eclipse plugin is not properly installed. Check from: Help -> Install New Software -> Already Installed -> Features -> Feature Id: org.maven.ide.eclipse.feature -> Plug-in Details that there is Plug-in Id with org.maven.ide.eclipse.launching and of course that there’s no errors in the Maven plugins.
I’ve tested this on 0.9.9 development version of m2eclipse, but it seems that there’s 0.10.0 out and the update site given above has become dysfunctional. I’ll check that out straight away and update the post afterwards.
Note to others updating to 0.10.0 that it’s required to uninstall your 0.9.9 version before updating.
My original install was 0.10. There are no org.maven.* feature or plugin ids listed. I reinstalled 0.10 from http://m2eclipse.sonatype.org/sites/m2e, Seemed to install OK (again) but still no ids :-S
Gave up on eclipse. Running “mvn gae:run” from command line seems to cause the app to launch, but then get the following error with first hit:
SEVERE: Error compiling file: …jsp//org/apache/jsp/guestbook_jsp.java
…
[javac] class file for PersistenceManagerFactory not found
[javac] PersistenceManager pm = PMF.get().getPersistenceManager();
Would be very cool to get this going.
I have no idea about this. I can verify that the current version (just released a new one) works perfectly well in Maven, even on a clean environment. Just by running:
and after that in the created project’s directory:
Replace the
/usr/local/lib/appengine-java-sdk-1.3.1/with whatever is the path to App Engine home directory in your environment.Lathered, rinsed, repeated and it worked this time (the persistence jars were not included correctly for some reason the first time). Thanks! Just need to get eclipse going now. Last time I worked with maven/eclipse a year ago it was ugly as well.
I upgraded to 0.10.0 today and it works. Maybe you should check the log why the plugin doesn’t get installed.
There was no dialog with error on install and could not find any logs in .eclipse nor workspace .metadata that mentions install errors.
“Maven Integration for Eclipse” shows up as installed software, and there are the following jars under .eclipse plugins:
./org.maven.ide.eclipse_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.editor_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.editor.xml_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.jdt_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.launching_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.maven_model_edit_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.pr_0.10.0.20100209-0800.jar
./org.maven.ide.eclipse.refactoring_0.10.0.20100209-0800.jar
but none of them contain a Maven2Builder* class (very suspicious).
Anyway, don’t mean to waste your time on this. Thanks for the post.
Maven2BuilderConfigurationTypeseems to be mapped at ./org.maven.ide.eclipse.launching_0.10.0.20100209-0800.jar/plugin.xml toorg.maven.ide.eclipse.internal.launch.MavenLaunchDelegateclass which can be found in the same archive. So the problem must be a plugin installation failure. I’d suggest you to try installing the plugins to a fresh Eclipse installation.Impressive! It worked just like you said without flaw. I even upgraded to 1.3.4 by changing the property gae.version and it all seemed to work fine inside of Eclipse.
I switched over to the command line and ran a few commands. Upgraded the maven-gae-plugin version to 0.59 to match the latest and that all worked fine.
Thanks for doing all this work. Looking at the pom this was no small feat and I don’t know that I could have gone forward with App Engine without both Maven and Eclipse…so I likely would have dove in the way you did. I’m glad I didn’t have to!
Aaron
I’m glad that it works for you. I will upgrade the archetype to include the newest versions of both App Engine and the Maven plugin. Anyway, thanks for making my day!
I had the same problem using this,
Launch configuration type id “org.maven.ide.eclipse.Maven2BuilderConfigurationType” does not exist.
I fixed below line in launch file to solve the problem and it seems fixed, no more error messages.
@Golf, The line that you fixed in the launch file doesn’t show in your post. I am stuck with this same issue, please share how you fixed it.
OK, it seems like maven external tool builder has been removed from m2eclipse. see http://issues.sonatype.org/browse/MNGECLIPSE-2269
Check out the Helios solution it should work out!
Thanks!
I did everything like you explained and it’s working fine! I’m now working in Eclipse 3.6 (Helios) with latest version of Maven and GAE, Spring 3.5 and everything is running very smoothly!
I’m currently running with a small .bat file which basically just sets my gae.home folder and runs mvn gae:run and i’m running with a similar file for deployments.
Thank you for the great article!
Keep it up ;)
Hi all,
we recently experienced this same issue when receiving am application developed by an external consultancy. The web application had been built using Maven 2.0.9 and Eclipse 3.4 or 3.5.
We are using Springsource Tool Suite – based on Eclipse 3.6, and when we loaded up the (multi-module) project, we observed the following error:
Launch configuration type id “org.maven.ide.eclipse.Maven2BuilderConfigurationType” does not exist.
Now, the important thing is how to fix this. As Neil pointed out above, the maven external tool builder has been removed from the m2eclipse plugin, so the solution is to get down and dirty and edit the .project file(s).
It will look something like this:
tims-excellent-project
org.eclipse.wst.common.project.facet.core.builder
org.eclipse.jdt.core.javabuilder
org.eclipse.wst.validation.validationbuilder
org.maven.ide.eclipse.maven2Builder
org.maven.ide.eclipse.maven2Nature
org.eclipse.jem.workbench.JavaEMFNature
org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.jdt.core.javanature
org.eclipse.wst.common.project.facet.core.nature
We found that removing the maven2Builder buildCommand element, as well as the maven2Nature element solved our problem. Save the file, reload your project, and the problem should go away.
So for completeness, our .project file now looks like this:
tims-excellent-project
org.eclipse.wst.common.project.facet.core.builder
org.eclipse.jdt.core.javabuilder
org.eclipse.wst.validation.validationbuilder
org.eclipse.jem.workbench.JavaEMFNature
org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.jdt.core.javanature
org.eclipse.wst.common.project.facet.core.nature
Hope this helps!
Cheers,
Tim
OK, so the formatting of the above .project file contents isn’t brilliant. Many apologies, but I don’t know how to do it, and there doesn’t seem to be anything obvious. I tried surrounding it with code tags – to no avail. How did hleinone do it?
If I do a Google search, all I get is information for blog writers on plugins – nothing for people leaving comments.
Aaaarrrghrgrhhhh!
For me it looks fine with the
<code>tags. If you want more fanciness, use the[sourcecode]tags. You should use them both like XML tags, so before your code snippet put[sourcecode]and after it[/sourcecode]. Like this:Probably if you’d let the m2eclipse generate the project files again it wouldn’t generate those builders that no longer exist. If it still does, there has to be something in the POM telling it to do so. Same goes if you’re using
mvn eclipse:eclipsefor generating your Eclipse project files.