Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Play Framework with Google App Engine with locally installed Java 7?

I've just downloaded the latest version of the Play Framework (1.2.3) and am using it with the latest Scala plugin (0.9.1) and the Google App Engine module (1.4).

The default application works fine locally (at localhost:9000, the default port). I've also successfully published the default application to GAE using play gae:deploy.

However, when I go to the GAE remote URL, I get the standard error message:

Error: Server Error.
The server encountered an error and could not complete your request.

If the problem persists, please report your problem and mention this error message and the query that caused it.

Here is the full stacktrace in the GAE logs: https://gist.github.com/1181257

I'm guessing the first error, the NPE, is due to something that can be easily fixed, so ignore that for now; however, note the second - critical - error, which says:

java.lang.UnsupportedClassVersionError: helpers/CheatSheetHelper$1 : Unsupported major.minor version 51.0

51.0 is (I think) the class version that the Java 7 compiler generates. Now, my question is simple:

How to force the Play Framework and its Scala plugin to compile the classes for GAE publishing using the -target 1.6 and -source 1.6 options, so that the output classes are 1.6 compatible, instead of the defaults, which make the local Java 7 installation generate 1.7 output classes?

Thanks.

[edit] As for the NPE, it seems that it's not thrown on Play 1.2.1 and the 0.9 version of the Scala plugin: Play framework with scala and GAE - again, this is just a side issue, the primary issue (getting Java 7 working) still stands. I've created a ticket for this: http://play.lighthouseapp.com/projects/74274-play-scala/tickets/45-nullpointerexception-on-google-app-engine

like image 354
Sandro Gržičić Avatar asked Aug 30 '11 16:08

Sandro Gržičić


3 Answers

To get java 7 to work currently, you have to use the following configuration in your application.confirm file

java.source=1.6

See here for more details - VerifyError; Expecting a stack map frame in method controllers.Secure$Security.authentify

like image 60
Codemwnci Avatar answered Oct 14 '22 08:10

Codemwnci


Java 7 is fully supported for Play 1.2.4 RC3 - give it a try and see if it solves your issues.

like image 35
ripper234 Avatar answered Oct 14 '22 06:10

ripper234


I just ran into the same issue. I'm running Java 7 and don't want to have all my other Java stuff run on 6 again. So, what I did was dump a copy of JDK 6 in a directory and then made a simple bash script to set the proper environment vars and call play. I then symlinked that script as "play" on my path. Now when play gets called it has a JDK 6 environment to run under without having to change everything else on the machine.

...less than ideal, but it works well enough and keeps everything clean.

like image 43
user605331 Avatar answered Oct 14 '22 08:10

user605331