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.
#1 by Alessio Spadaro on July 15, 2009 - 09:12
Hi,
i’m experiencing the same problem, but i didn’t have time lately to see in to this.
Following the bug opened on gae (issue 1862) i found a thread reporting this hint:
DataNucleus provides a JAR containing the Enhancer ( datanucleus-enhancer.jar ). From J2SE 1.6 and forward, you can automatically enhance your classes when compiling your classes. Just add the datanucleus-enhancer.jar , datanucleus-cor.jar , jdo2-api.jar and asm.jar to the compiler classpath and the classes will be enhanced.
(from http://www.jpox.org/servlet/forum/viewthread_thread,5394_offset,10 )
Under the assumption of using java6, this seems a good candidate for disabling the enhanching-stage, doesn’t it?
Best,
Alessio
#2 by admin on July 15, 2009 - 21:45
@Alessio Spadaro
I agree, this would most likely be the best option for getting Grails to work on Windows machines. Atleast until we see some new releases of the enhancer. I’m not hoping for Microsoft to drop a hot-fix for this issue.
I will see if this is a valid solution. If I find one I will naturally blog about it and inform on grails.org.
#3 by Andy on July 19, 2009 - 08:22
> I tried using the Datanucleus tool directly without success.
> …
> are not named according to how Datanucleus would like it.
Perhaps state which DataNucleus tool, and what is “without success”, and then mention what is “not named according to how DataNucleus would like it”.
DataNucleus has no reported issues relating to Grails, so we’re unlikely to respond when we don’t know about something …. other than just happening to come across someone’s blog ….
#4 by admin on July 24, 2009 - 21:22
I’m not sure you bothered to read the post.
The issues is with enhancing the domain-classes using the datanucleus enhancer. Now the enchancement in Grails is done using Google’s ant macros. The commandline arguments to the enhancer becomes too long to execute on windows.
You can see the problem described on googles FAQ http://code.google.com/intl/nb/eclipse/docs/faq.html#datanucleuswindowserror, also noted in the post.
It’s the enchancer tool that doesn’t run.
When running the enhancer from the commandline my classes aren’t enhanced. They complain that they cannot find the packaged files.
For example running the enhancer on the classes in the package Test, causes an error saying that it can’t find the class named Test.Classname.
I’m quite sure that datanucleus enhancer tool runs perfectly with Grails, but I can’t get it to work on my x64 Windows Machine.
I will continuously post updates as I progress. I do not blame Datanucleus for any of the above stated problems. I believe that these are configuration issues, but I’m merely trying to help others whom run into the same issue. Nor have I contacted Datanucleus, since I do not believe that the issue is with Datanucleus software. I’d rather have a more concrete description of a potential problem before posting an issue.
But I’m glad you noticed my post, hopefully during the next week there will be a new post with a suggested resolution.
#5 by admin on July 26, 2009 - 22:17
If the previous reply seemed harsh it was not my intention. I appologies if the reply came out wrong.
#6 by Andy on July 31, 2009 - 17:14
No problem. I did read it, honest
My point with “which tool” is that the DN enhancer can be run from the command line (with certain input), or via our Eclipse plugin (not Googles), or via Ant, or via Maven, or at runtime. Hence there are various “tools” that you may have been using. You said later you’re using command line, so that answered the question. PS. I’m not from a Grails background so that side of it wouldn’t make sense to me either way
#7 by Erik Bengtson on August 26, 2009 - 15:52
To avoid the 8192 limit, you can also disable fork when running your ant tasks
#8 by admin on August 27, 2009 - 08:49
I tried modifying the ants file so it wouldn’t fork. I couldn’t get it to work. If you have a working copy I’d be happy to update the post with it.