Play! framework is gaining popularity and the following topics already exist on Habré:
Excellent Java MVC framework - Play Framework'Hello World' tutorial - your first application on the Play framework (Part 1)'Hello World' tutorial - your first application on the Play framework (Part 2)My 5 favorite features in the Play FrameworkOne of the great features of Play! - Deploying the application to Google’s
App Engine cloud infrastructure.
')
For applications that are executed in GAE, there are quite stringent (compared to conventional Play! Applications) limitations, mainly due to the data storage module (JPA / Hibernate). In order for the application to work without any problems in GAE, you should abandon JPASupport / Model helpers and use only the basic features of JPA.
An alternative could also be the use of the
Siena module.
In this topic, I will step by step describe the process of deploying the Play application! in Google AppEngine.
The process of installation and use is described in relation to the Linux operating system, but there should be no significant differences when using other operating systems.
The absolute paths in the examples of commands are intentionally left for clarity. Installation was carried out in the user's home directory. If you wish, you can always add a path to the Play! in PATH.
1. Download the latest version of the framework from the developers site
(You can also get the latest version from github:
www.playframework.org/code )
cd
wget download.playframework.org/releases/play-1.2.1.zip
unzip play-1.2.1.zip
cd play-1.2.1/
2. Download AppEngine SDK for Java
wget googleappengine.googlecode.com/files/appengine-java-sdk-1.5.1.zip
unzip appengine-java-sdk-1.5.1.zip
3. Install modules for working with GAE and Siena
/home/albert/play-1.2.1/play install gae
/home/albert/play-1.2.1/play install siena
We answer "y" to questions, then the modules will be automatically downloaded and installed.
4. Create an account and app on appengine.google.com
(login by Google account, phone number must be confirmed, then you can create up to 10 AppEngine applications).
Learn more about GAE here:
code.google.com/intl/ru/appengine5. Preparing the application for deployment
In order not to waste time on the description of the process of creating the Play application! We will deploy the sample application from the /home/albert/play-1.2.1/modules/gae-1.4/samples-and-tests/lists-with-gae directory, which comes with the
gae module.
Since the example application was created using the outdated version of the siena module, in the configuration /home/albert/play-1.2.1/modules/gae-1.4/samples-and-tests/lists-with-gae/conf/application.conf we specify the path to the new version of siena, for which line
module.siena=${play.path}/modules/siena-1.3
replace on
module.siena=${play.path}/modules/siena-2.0.1
Make sure the application works locally:
cd /home/albert/play-1.2.1/modules/gae-1.4/samples-and-tests/
/home/albert/play-1.2.1/play run lists-with-gae
At the same time, the application will start in development mode (DEV mode) and we will be able to access it at the address
localhost : 9000 /
6. Specify the AppEngine application ID.
In the /home/albert/play-1.2.1/modules/gae-1.4/samples-and-tests/lists-with-gae/war/WEB-INF/appengine-web.xml file
we specify the identifier of the application created in item 4 in on AppEngine
7. Precompile the application.
/home/albert/play-1.2.1/play precompile lists-with-gae
/home/albert/play-1.2.1/play war lists-with-gae -o /tmp/lists-with-gae.war
8. Actually deployment
/home/albert/appengine-java-sdk-1.5.1/bin/appcfg.sh update /tmp/lists-with-gae.war
Enter the email and password for the Google account in which we created the GAE application and wait for the deployment to complete.
You can also fully deploy (items 7. and 8) with one command:
/home/albert/play-1.2.1/play gae:deploy lists-with-gae --gae=/home/albert/appengine-java-sdk-1.5.1
9. Test the application
We contact the address of our application (in the example
appgoer.appspot.com ) and observe the running application. Your appgoer should be replaced with your ID.
In case of any difficulties, all application logs are available in the GAE admin panel.
10. Let's play!