{"id":238,"date":"2011-01-08T08:53:40","date_gmt":"2011-01-08T15:53:40","guid":{"rendered":"http:\/\/journeyman.ivystreetinc.com\/?p=238"},"modified":"2011-01-08T08:59:51","modified_gmt":"2011-01-08T15:59:51","slug":"grails-app-on-google-app-engine","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=238","title":{"rendered":"Grails App On Google App Engine"},"content":{"rendered":"<p>I wanted to collect things I know about the health care process into an application and decided a Grails app running on Google App Engine would be a fun way to go.\u00a0 This is how I got things launched, and you might be able to use this for your app.<\/p>\n<p>The reason I chose the Google platform was cost.\u00a0\u00a0 The idea of an Amazon EC2 environment and platform as a service really appeals to me, and in fact this site is served up from a PHP\/Servlet container Linux server I rent on my ISP provider.\u00a0 But a lot of the providers cost quite a bit more than I want to spend now to play with concepts.\u00a0 Google is a bit quirky but I think in the future the cloud platforms will be much more standard and accommodating to widespread tech and code &#8212; seems to be where Amazon, Salesforce, VMWare etc. are all heading.\u00a0 Some of us will write the code that binds it &#8212; just like no one worries about connection pooling anymore, a lot of the stuff will become transparent and we can just <em>code<\/em>.\u00a0 Not today though.<\/p>\n<p>And a lot of times, I don&#8217;t want to be a programmer per se, instead, I just want to do make my idea real.\u00a0\u00a0\u00a0 I am hoping the Google platform can help me do this quickly.<\/p>\n<p>Before you start, you&#8217;ll have to get a Google app engine account using your cell phone because they will SMS text a confirmation number to you.\u00a0 I wasn&#8217;t confortable doing this, so at Walmart I picked up a TracFone pay as you go for $10, and it had 20 total minutes that came free with it.\u00a0\u00a0 I priced out other could platforms and you have to really pay big (Although now Amazon has a year of free services for new people on a small scale).\u00a0 $10 for my piece of mind seems reasonable.\u00a0 Also &#8212; a cool phone for $10 is quite amazing, I was shocked.\u00a0\u00a0 I&#8217;ll probably write an article up on the Ivy Street Design site about it.\u00a0 But Onto Business.<\/p>\n<p>How to get a Grails App Up onto Google Apps, in Meta terms.\u00a0\u00a0 I am assuming the person reading this is already a Grails developer familiar with fundamental actions.<\/p>\n<p><strong>Setup<\/strong><\/p>\n<ol>\n<li>Get a Google App Engine account.<\/li>\n<li>Choose a name for your app and set up an application space in it.\u00a0 It will end up being something like &#8220;&lt;yourapp&gt;.appspot.com&#8221; for the url, since appspot serves them up at Google.<\/li>\n<li>OK &#8212; you should have your IDE and machine set up for Grails.\u00a0\u00a0 I&#8217;m not going through it so make sure GRAILS_HOME and GROOVY_HOME environment is set up in your environment (with the \/bin&#8217;s in the PATH, just like the JAVA setup you should have done).<\/li>\n<li>Download the Google Apps SDK for Java on their site.\u00a0 Unzip it to your library spot then, set up the APPENGINE_HOME env variable and add the \/bin to the PATH variable.<\/li>\n<li>Test your setup quick.\u00a0 Open a terminal up and type in and test each of:\n<ul>\n<li><code>groovy -version<\/code><\/li>\n<li><code>groovy -version<\/code><\/li>\n<li><code>appcfg -h<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Create a grails application in your IDE.<\/li>\n<li>OK &#8212; important &#8212; you will have to remove the hibernate plugin from your project if it is in there (Google App Engine cannot run full blown hibernate).\u00a0 Also, I removed the tomcat plugin. Since I am using Netbeans as my IDE for this it might have thrown that in there.<\/li>\n<li>Install the app-engine plugin into your project.<\/li>\n<li>Configure appengine-web.xml in your app directory.\u00a0 Set &lt;application&gt; to the name of your target app in Google App Engine, and the &lt;version&gt; number.<\/li>\n<\/ol>\n<p><strong>Run the App<\/strong><\/p>\n<p>Now that you are set up you can run the app in the local app engine that you downloaded with the Google Java SDK.\u00a0 I found that the Netbeans plugin for Google App Engine not too helpful at all &#8212; it wouldn&#8217;t let me add a Grails app to the server.\u00a0 You can find it on the Kenai.com site, or maybe have better luck with Eclipse.\u00a0 For now though running from the command line is good.\u00a0 Should know how to do that anyway.<\/p>\n<p>Go to your Grails application directory.\u00a0 and execute:<\/p>\n<p style=\"padding-left: 30px;\"><code>grails app-engine run<\/code><\/p>\n<p>It will take a bit for it to build and run, but the command line will tell you its ready and you can go to http:\/\/localhost:8080\/ and see your app.\u00a0 Also note that the <a href=\"http:\/\/localhost:8080\/appEngineReload\/index\">org.grails.appengine.AppEngineReloadController<\/a> will show up under the controller list.<\/p>\n<p>I just ctrl-c out of the service to stop it.<\/p>\n<p><strong>Upload the App<\/strong><\/p>\n<p>It&#8217;s simple to do this from the command line in your project&#8217;s directory.<\/p>\n<p>Optional, set the version:<\/p>\n<p style=\"padding-left: 30px;\"><code>grails set-version 1<\/code><\/p>\n<p>Now package up the app:<\/p>\n<p style=\"padding-left: 30px;\"><code>grails app-engine package<\/code><\/p>\n<p>Then, upload:<\/p>\n<p style=\"padding-left: 30px;\"><code>appcfg update .\/target\/war<\/code><\/p>\n<p>You&#8217;ll be prompted for your ID\/password on the command line.\u00a0 It won&#8217;t take long &#8212; and you will see your application served upp at &lt;yourappname&gt;.appspot.com.\u00a0 Make sure to check out the administrative console on Google as well for your app.<\/p>\n<p>My next step will be to delve into BigTable and the possible ORM functionality I can do, as well as work on my app.\u00a0 I&#8217;m working on some writings about the NoSQL technology, should be fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to collect things I know about the health care process into an application and decided a Grails app running on Google App Engine would be a fun way to go.\u00a0 This is how I got things launched, and you might be able to use this for your app. The reason I chose the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/238"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=238"}],"version-history":[{"count":4,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":240,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions\/240"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}