views:

143

answers:

2

Hi,

I'm running through the Ruby on Rails tutorial at http://guides.rubyonrails.org/getting_started.html (adjusting where appropriate for Google's App Engine). All is well up till section 6.3: when I try to click "New Post", I get the following error:

Internal Server Error (500)  
Request Method: GET  
Request URL: http://localhost:8080/500.html  
access denied (java.io.FilePermission /dev/urandom read)

It works fine when I upload the application to Google's App Engine; it's just on my development machine (OS X 10.6) that it doesn't work.

Thanks in advance.

EDIT: I've just tested a simplification to the problem: even when just running through the steps at gist.github.com/268192, I get the same error when clicking "new contact" (or similarly when navigating to localhost:8080/contacts/new).

Strangely, when I go through the steps for building a guestbook with Sinatra (code.google.com/p/appengine-jruby/wiki/GettingStarted) it works fine, including saving to the development store.

A: 

You have not setup your database in your development machine. do a rake db:create:all and then run a migration rake db:migrate

Shripad K
Is that necessary? I'm using DataMapper, and as per the instructions at http://gist.github.com/268192 I'm using --skip-migration when creating the controller.
Phillip Parker
@Paddy: Just in case, I tried the steps you mentioned. Still the same error unfortunately
Phillip Parker
Ok i really have no idea about datamapper as i never used it in any of my projects. "Internal Server Error: 500" generally hints the non existence of the database. Do you have a database configured for this app? If you using MySQL/Postgresql, do check if the server is up and running in the MacOSX prefpane.
Shripad K
I'm really really new to Rails and Google App Engine, so I'm not totally sure if I'm say the right things, but the project uses rails_dm_datastore and activerecord-nulldb-adapter, meaning there isn't a database like MySQL or Postgresql, but rather a development version of Google's data store (from what I can tell...)
Phillip Parker
Besides, while it might be a red-herring, the key issue seems to be the last line: access denied (java.io.FilePermission /dev/urandom read), although I don't really know why that would be occurring.
Phillip Parker
Let me be honest with you. I have never hosted an app on the Google app engine simply because i always thought it was mainly for python based apps. After scouring the web i realized you can host Rails apps on Jruby. Now thats an area that i have no experience in. From the gems that you listed, activerecord-nulldb-adapter doesn't really depend on a database (used for testing purposes) so that gives me no info about your problem. And datastore/bigtable is the Google proprietary database engine. So i don't know whether it will work locally on a development build as you need database access.
Shripad K
Ok i don't really know how this would work for you. But you can use the BigTable Webservice to store data from your local development machine. http://bigtable.appspot.com/Create your account and create the same table that you used.
Shripad K
I'll have a look at that, thanks. From what I understand from the documentation for app engine there's a local version of the data store for development purposes... Could be wrong though. Thanks again for the assistance.
Phillip Parker
Ok i did try the bigtable webservice. I used typhoeus gem to send the PUT and GET requests. This gem makes it really easy to do that and is super fast compared to the native net/http. And it does work. If you can find a way to connect your app to the bigtable Webservice then it will be great. I will by then read the app engine documentation and get back to you.
Shripad K
Sorry, i forgot to mention this: `http://github.com/pauldix/typhoeus`Easy to do HTTP requests, very fast.
Shripad K
Thanks heaps for the effort. For the moment I think I'll stick with using DataMapper with nulldb (still don't quite get how it works though), since it works fine when I publish the app to appspot. A little inconvenient, but that's ok.
Phillip Parker
Oh, and typhoeus looks very useful. I have that bookmark for later use.
Phillip Parker
A: 

I suggest triple checking your routes.rb file to make sure you haven't got any errors in there.

Also, try jruby script/console and see if you can access the DB from there.

What version of JRuby are you on?

Rob
Couldn't get it to work from script/console, but I only tried quickly so I'm not sure exactly what was happening... JRuby version is whatever is packaged with app engine; it uses it's own "frozen" version of JRuby (see http://code.google.com/p/appengine-jruby/wiki/InstallEverything)
Phillip Parker