portable perspectives

a blog about programming, life, universe and everything

Using Scala with Google App Engine

I just got access yesterday to the new Google App Engine for Java SDK, and I thought it would be fun to check if Scala works on it.

Well, it does.

Fow what is worth, I followed the standard procedure outlined in the google documentation and I was able to run my small servlet from eclipse, in java.

Simple steps to get your scala app on google app engine

  • download the GAE plugin for ecplise
  • download, if necessary, the scala plugin
  • create a new Google Web app project
  • add "scala nature" to the project
  • define a new Scala class as an ancestor to the existing servlet, letting the former implement the servlet behaviour

After this the basic servlet that was managed as the main run configuration from eclipse still worked correctly, meaning I could run it, stop it and deploy everything correctly. Adding a few other Scala classes still let the thing work nicely.

It was obviousl possible at this point to delete the old useless java class and just keep the scala servlet. A pure scala app is now able to run on google app engine.

After that, I'd have loved to build a tiny online REPL (at least I know that nothing bad will happen as google took care of the sandboxing) but while I was trying to use the existing scala.tools.nsc.Interpreter class I hit a problem causes by that same sandbox: it seems that the Scala code accesses the file system (mostly calls to File.isDirectory and similar), and those are caught by the SecurityManager who raises an AccessControlException. Eh, just what I asked for :)

Probably it is possible to work around this issue somehow, but it seems It would require more knowledge than that I currently have, so I'm leaving it until I have more time and experience.

For those not interested in using eclipse a nice writeup of the steps necessary to use Scala with GAE are here, it is again pretty simple, and it is probably a better approach.

AddThis Social Bookmark Button

Sorry, comments are closed for this article.