Home > Uncategorized > Grails and Google AppEngine on Windows

Grails and Google AppEngine on Windows

In a previous post I described a problem where the app-engine command would fail when enhancing the domain objects for persistence.

The problem was that the command line became too long to execute on windows, when executing the enhancement task.

I’ve been working on several workarounds for this problem.

  • Enhancing the classes during compilation
  • Enhancing the classes manually
  • Enhancing the classes programmatically
  • Modifying the ant target to produce shorter command line calls

Enhancing during compilation

Make sure you have version JDK 1.6 and add the enhancer and its requirements to the compilation class-path. Produces no errors during compilation, but no enhancement is done. Fails when not all libraries included, so something is happening. I’m not sure it can find the persistence.xml file to use.

Enhancing the classes manually

I had problems where the enhancer wouldn’t find the domain objects when compiled into a package. It would say that the classes we’re not included in my class-path, even though they were.

However, working with the manual enhancement I found a wonderful option called checkonly. So you could set the enhancement tool to just check if the classes are enhanced. This would be a excellent extra option for the grails app-engine plug-in, if you could call grails app-engine diagnostic and see which files that are enhanced.

Enhancing the classes programmatically

This seems to be a viable option. I modified the app-engine plugin for grails to do the enhancement programmatically, however it failed to enhance the files with two problems. Out of the box, the persistance.xml file is not located where it should be to enhance the compiled classes. It must be copied to a location where the enhancer can find it. The other problem was that of how grails organizes its compiled files.

Modifying the ant target to produce shorter command line calls

This is what I’ve got working right now. In the Google SDK I modify the ant-macros.xml

<macrodef name="enhance_war" description="Run the ORM enhancer on an exploded war">
 <attribute name="war" description="The exploded war directory containing the application"/>
 <element name="args" optional="true" description="Additional arguments to the enhancer"/>
 <sequential>
 <enhance failonerror="true" >
 <args/>
 <classpath>
 <pathelement path="${appengine.tools.classpath}"/>
 <pathelement path="@{war}/WEB-INF/classes"/>
 <fileset dir="@{war}/WEB-INF/lib" includes="*.jar"/>
 </classpath>
 <fileset dir="@{war}/WEB-INF/classes" includes="**/*.class"/>
 </enhance>
 </sequential>
 </macrodef>

becomes

<macrodef name="enhance_war" description="Run the ORM enhancer on an exploded war">
 <attribute name="war" description="The exploded war directory containing the application"/>
 <element name="args" optional="true" description="Additional arguments to the enhancer"/>
 <sequential>
 <enhance failonerror="true" >
 <args/>
 <classpath>
 <pathelement path="${appengine.tools.classpath}"/>
 <pathelement path="@{war}/WEB-INF/classes"/>
 <fileset dir="@{war}/WEB-INF/lib" includes="*.jar"/>
 </classpath>
 <fileset dir="@{war}/WEB-INF/classes/persisted" includes="**/*.class"/>
 </enhance>
 </sequential>
 </macrodef>

Now all my domain classes that requires persistence is in a package called persisted.  The macro should be modified to fit your needs or find a convention to follow in all your projects running on Google AppEngine.

Bookmark and Share
  1. August 26th, 2009 at 21:35 | #1

    Thanks for posting this – fixed the issue I was having. While I am at it, thanks for posting the Tutorial on GAE, following that one to get comfortable with GAE / Grails.

  2. admin
    August 27th, 2009 at 08:31 | #2

    Thanks for the feedback! I greatly appreciate it.

  3. September 9th, 2009 at 06:02 | #3

    Thanks for the post, solved my issue too and saved me a lot of time going through all the other alternative workarounds. I made a minor change to use ”
    “includes=”**/*Domain.class” pattern instead.

  4. Christian Naeger
    September 20th, 2009 at 01:34 | #4

    Hi, thanks a lot. This problem killed my last 5 hours! I would not have been able to solve the problem on my own. Your solution does work! Thanks a lot!!!
    I also liked your tutorial. Very concise! Regards, Chris

  5. January 9th, 2010 at 13:24 | #5

    This was a life saver, my friend. Thank you. I cannot believe that this process is so fragile and who thought it was a good idea to enhance every single class in the class path. Geesh!!! lol. Hopefully, ides’ will be tooled to configure this xml file in the future on a per project basis.

    I wish this fix were more ‘public’ because it took me hours to find it :(

    Thanks again.

    Jeff

  6. Morten
    January 12th, 2010 at 09:25 | #6

    @Jeff
    Hi Jeff, if you want to help make this issue more “public”. Please provide trackbacks or links to this page. It helps give it a better ranking in Google.

  7. March 30th, 2010 at 23:26 | #7

    A slight update on this issue can be found here:
    http://www.morkeleb.com/2010/03/30/interesting-issue-on-gae-issue-list/

  1. July 27th, 2009 at 21:35 | #1
  2. December 13th, 2009 at 18:59 | #2
  3. March 30th, 2010 at 23:25 | #3