Sinatra on Google App Engine
Monday 05/18/2009 – Category: Uncategorized
I attended a JRuby on Google App Engine talk during Railsconf and have been anxious to try deploying a Ruby application on the platform. This tutorial gives a good walkthrough and I was able to get a Sinatra app up and running on GAE, but not without a few hiccups and hurdles.
Some things I ran across:
- You need to have Java enabled on your GAE account. It can take up to a few days to get approved for the early look program.
- The rflickr gem I'm using in my Sinatra app relies on on xmlrpc and net:http which can't be used on GAE and was raising this error:
java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
- Since GAE uses its own URL fetch library in place of net/http, you can get xmlrpc to work by doing this (thanks Ryan Brown!):
require 'appengine-apis/urlfetch' Net::HTTP = AppEngine::URLFetch::HTTP
- After I did that, the thread error went away, but I got a different error:
NoMethodError - undefined method `as_java_bytes' for #<String:0x440543>
- This time it was just a typo in the appengine-apis-0.0.4 gem. line 142 of urlfetch.rb needs to be:
request.set_payload(payload.to_java_bytes)
instead of
request.set_payload(payload.as_java_bytes)
- It takes quite a while to spin up the app for the first request...I'm not sure if there's any way around that other than setting up something to ping the app every so often
Leave a Reply
Recent Posts
- Good Word – now with definitions!
(Friday 03/5/2010 – 2 Comments) - Good Word – Words With Friends Word Checker
(Thursday 02/25/2010 – 31 Comments) - Facebook App Development gotchas
(Friday 02/19/2010 – No Comments) - StoreKit SKErrorUnknown
(Friday 02/19/2010 – 1 Comment)
