RUN@cloud » Deploying Play 2.0 as a WAR (deprecated)

Deploying Play 2.0 as a WAR (deprecated)

Last modified by Spike Washburn on 2013/03/21 17:01

This article is out of date.  Please see Play2 Docs instead for the latest information about deploying Play2 applications natively (this doc describes how to deploy play as a WAR file, which is no longer required).

Getting Started

CloudBees SDK

To deploy a play2.0 the CloudBees SDK is needed.

Getting the framework

Play2.0 can be downloaded from here.

Setting up the framework

Unzip the play zip file you just downloaded to any path that suits you. You'll need to add that folder to the the system path.

Creating a new web application

11:20 ~/CloudBees $ play new cb-test-deploy
       _            _
 _ __ | | __ _ _  _| |
| '_ \| |/ _' | || |_|
|  __/|_|\____|\__ (_)
|_|            |__/
            
play! 2.0, http://www.playframework.org

The new application will be created in /Users/ivan/CloudBees/cb-test-deploy

What is the application name?
> cb-test-deploy

Which template do you want to use for this new application?

 1 - Create a simple Scala application
 2 - Create a simple Java application
 3 - Create an empty project

> 1

OK, application cb-test-deploy is created.

Have fun!

Deploying play with CloudBees

Use the native play support. The following shows how it can be done with war files, which is another approach.

play SBT plugin for creating war files

Thanks to Damien Lecan for creating a play2-war-plugin. With this play2 apps can now run on the jee 6 web profile on CloudBees.

In APP_HOME/project/plugins.sbt, add:. 

resolvers += "Play2war releases" at "http://repository-play-war.forge.cloudbees.com/release/"

addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "0.7.3")

 

In APP_HOME/project/Build.scala, modify appDependencies and main values to add:

val appVersion      = "1.0-SNAPSHOT"

val projectSettings = Play2WarPlugin.play2WarSettings ++ Seq(
 // Your settings
)

...

val main = PlayProject(
   appName, appVersion, appDependencies, mainLang = JAVA
).settings(projectSettings: _*)

 

Create a file APP_HOME/conf/logger.xml with the following content  to set up logging properly:

<configuration>

 <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
   <encoder>
     <pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
   </encoder>
 </appender>

 <logger name="play" level="INFO" />
 <logger name="application" level="INFO" />

 <!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
 <logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
 <logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
 <logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />

 <root level="ERROR">
   <appender-ref ref="STDOUT" />
 </root>

Creating the war file

You should now be able to run

play package

Uploading to CloudBees RUN@Cloud

Once you have the war file created run the following:

bees app:deploy -a <appid> -t jboss target/<war file>
bees app:update <appid> disableProxyBuffering=true

Without the second command the CloudBees routing layer will not work correctly with play2.

Your app should now be running on CloudBees!

Tags:
Created by Ivan Meredith on 2012/04/08 00:16