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.
Pingback: Building Blocks » Grails and Google AppEngine
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.
Thanks for the feedback! I greatly appreciate it.
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.
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
Pingback: Building Blocks » AppEngine enhancer issue
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
@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.
Pingback: Building Blocks » Interesting issue on GAE issue list
A slight update on this issue can be found here: http://www.morkeleb.com/2010/03/30/interesting-issue-on-gae-issue-list/
Pingback: Using Google App Engine with Grails « Daniel Rosowski's Techblog
Hey,
Do you know when the plugin will be updated to work with Google App Engine?
Thanks,
Daniel
Hi! No sorry, I have no idea when it will be updated.