I suggest a temporary fix to the described problems here.

I’m porting my Grails project from Mor.ph to Google AppEngine. If your using Windows certain things will not work out of the box.

To be able to use GORM you need to install the GORM-JPA plugin. Now you should in theory be able to use the GORM dynamic functions.

Alas however installing the GORM-JPA plugin will make the packaging functions for Google AppEngine fail. Google has a step in the deployment process where they enhance the byte-code to allow storage in their storage solution.

You run into this error

... java.io.IOException: CreateProcess: ...

Windows can only support command-lines with a length of 8191. The enhancement step reaches this limit when enhancing Grails applications. The Eclipse plugin has this issue mentioned here.

I’ve tried the following workarounds, with no luck:

  • Running the packaging step in Powershell, hoping that powershell doesn’t have this limit.
  • Running the packaging step in Cygwin, hoping that the linux emulation would work around the process execution limit.

Currently I’m working on rewriting the ant macro for the enhancement step in Google’s SDK. There are some improvements that can be done.

This is what the macro looks like in ant-macros.xml

 <!--
 A macrodef for ORM enhancement for a war. Use like:

 <enhance_war war="${war}"/>  
 -->
 <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>

Notice that the class path argument contains a fileset of the lib directories. This can be changed to just include the path element, since Java will resolve the .jar files.

The second part of the problem is the argument fileset list

 <fileset dir="@{war}/WEB-INF/classes" includes="**/*.class"/>

Grails creates a lot of class files, so just fixing the class path will not fix the command line problem. Ive been working on excluding files that do not need enhancement, such as the app-engine plugin classes themselves. Another idea is to move the domain into its own package, thus its own directory. This however leads to issues with naming, apparently the compiled groovy classes are not named according to how Datanucleus would like it.

I tried using the Datanucleus tool directly without success.

The latest Idea I have is to somehow wrap into the compilation step of the grails war target and do the enhancement there, and turn the enhancement step off when using just the app-engine plugin.

Bookmark and Share