Deploying Play Framework 2 apps, with Java AND Scala, to Openshift


Let’s Play! in the cloud

A couple of weeks, Mark Atwood, Jorge Aliss, and me, Sebastián Scarano participated in Red Hat’s webinar LET’S PLAY! IN THE CLOUD: DEVELOPING JAVA WEB APPS ON OPENSHIFT

In the webinar Mark gave a neat introduction to Openshift, Red Hat’s free Platform as a Service:

Then we developed a basic contact manager web application, combining Java and Scala source code in the same Play 2 application, and deployed it on Openshift.

With this quickstart (https://github.com/opensas/play2-openshift-quickstart) you’ll be able to take any Play 2 application and deploy it on openshift. Just follow this instructions.

And here (https://github.com/opensas/play2-contacts-demo) you will find the contact demo app.

In the demo, in spite our internet connection conspiring against us, we managed to cover the following topics:

You can also check this article in which we explain in detail how we took advantage of the new “do-it-yourself” application type on Openshift to achieve native support for Play Framework application on Openshift.

So, if you want to start deploying your play apps on openshift right away, just sign up at openshift.com and enter PLAY!WEBINAR as promotional code, and you’ll get 3 gears, each with 1GB ram and 512 MB data space, for free.

Have fun playing on the cloud!

About these ads

15 responses to this post.

  1. Posted by spider on 1 May, 2012 at 23:20

    great work

    Reply

  2. Well, I followed the entire explanation from https://github.com/opensas/play2-openshift-quickstart , and this is what I get from the play log once my app is pushed to openshift:

    /var/lib/stickshift/……/demo/repo/target/start “-DapplyEvolutions.default=true” -Dhttp.port=8080 -Dhttp.address=…. -Dconfig.resource=openshift.conf
    bash: /var/lib/stickshift/……/demo/repo/target/start: Permission denied

    I built the play app on cygwin, and the execution bit is set on the start script.
    What do I need to do to fix this? Any tips appreciated :-)

    Reply

    • Hi wwwim, inspired by your comment I wrote another post giving some tips on troubleshooting Play Framework apps on Openshift – http://playlatam.wordpress.com/2012/05/09/troubleshooting-play-framework-2-apps-on-openshift/

      I suppose you are running it on windows (because of the cygwin stuff). I haven’t tested it on windows, I guess it should work, but it’s quite possible that you’ll find some error. Take into account thata right now, you are compiling everything on your machine to target folder, and then you are running it on a fedora-like box on openshift, so I’m not suprised you get errors.

      The las (a bit desperate) advice would be to boot with an ubuntu livecd (or install it on virtualbox) setup everything and try with that, just to check if the problem is the Window$ os.

      Reply

      • Thanks for the follow-up post! I logged in using ssh and saw that -although the “chmod” on the start script was executed successfully on my local staged build- on openshift the start script didn’t have the x flag. I chmodded it on openshift manually, and ran the ./runtime/repo/.openshift/action_hooks/start script, which worked just fine. (And yes, I went all the virtualbox way as well, running ubuntu, installing git, ruby, ssh, rhc etc on it, but it’s a huuuge workaround).

      • pretty glad I could help you, don’t forget to tell us what you developing with play and openshift…

  3. I’m just testing the deployment of a play2.1(-snapshot) app to a cloud service…

    However, I noticed that the apache server in front of the openshift play server does not pass HTTP status response codes correctly to the play app? For example, when form validation fails at the server, and the controller returns a badRequest() (HTTP 400 code), I get following error page:

    Bad Request

    Your browser sent a request that this server could not understand.
    Apache/2.2.15 (Red Hat) Server at play-wwwim.rhcloud.com Port 80

    While it should be really just the same form rendered with errors. For example, my login page is a form login with required fields. If any field validation error or other validation error occurs I return a badRequest() of the same page. It doesn’t render as should due to the apache in front of it… You can test this at http://http://play-wwwim.rhcloud.com .

    Am I missing something?

    Reply

  4. Posted by wim on 10 May, 2012 at 21:38

    Hmm, I only found out now that you already filed a bug for this: https://bugzilla.redhat.com/show_bug.cgi?id=813061 … Let’s hope it gets fixed soon! :-)

    Reply

  5. Posted by OlegYch on 25 August, 2012 at 15:37

    wouldn’t it be better to build app directly on openshift, maybe by just commiting sbt launch script instead of whole target/ ?

    Reply

  6. Posted by mudrek on 29 September, 2012 at 19:02

    is this Deploying works for play1 ?

    Reply

  7. good work.. thanks for sharing.. :)

    Reply

  8. Thanks for this article! Works like a charm and didn’t take me long at all to get play2 up and running on OpenShift. Unfortunately I realized that the “diy” (do it yourself application) don’t scale on OpenShift.

    I’m a bit worried about that as my application already runs a lot slower on OpenShift than on my local computer, both tested with local requests to avoid network latency etc.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: