poornerd

my thoughts on programming and other nerdy stuff

How to run a Play Framework Application in Tomcat or JBoss

| 1 Comment

So you have writ­ten an appli­ca­tion using Play! Frame­work 2.x and your Sys­tem Admin­is­tra­tor tells you that he won’t install Play! and that your appli­ca­tion needs to run in a sup­ported Java Servlet Con­tainer like JBoss, Tom­cat or Glassfish?

No wor­ries, you can use the play2-war-plugin to cre­ate a WAR file which can be deployed in a Java Servlet 2.5 or 2.3 spec Servlet Container!

Here is the Quick Guide for 2.1.x (mainly from stack­over­flow):

  1. Within plugins.sbt add:
    addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.1.1")

    Accord­ing to the project web page, you will need to pick the cor­rect Ver­sion for you Play! Frame­work version:

        Play 2.0 -> 2.0.4 : 0.8.1
        Play 2.0.5+       : 0.8.2
        Play 2.1 -> 2.1.3 : 1.0.1
        Play 2.1.4+       : 1.1.1
        Play 2.2.x        : 1.2-beta1 (unstable)
    
  2. Then within the Build.scala file add:
    import com.github.play2war.plugin._
    ...
    .settings(Play2WarPlugin.play2WarSettings: _*)
    .settings(Play2WarKeys.servletVersion := "X.X")
    

    The X.X needs to be changed to the required Java Servlet ver­sion (usu­ally 3.0 or 2.5 depend­ing on your con­tainer)

If you are using Play! Frame­work 2.2 then you can also try this method with­out the Plu­gin, just using sbt http://​play2war​.blogspot​.in.

If you have read this far, you may as well fol­low me on Twit­ter:

Author: poornerd

Tech­nol­o­gist, Entre­pre­neur, Vision­ary, Pro­gram­mer :: Grad­u­ated from USC (Uni­ver­sity of South­ern Cal­i­for­nia) with a degree in Com­puter Sci­ence. After 10+ years of free­lance con­sult­ing and pro­gram­ming, he co-founded Site­Force AG eBusi­ness Solu­tions in 1999 in Munich (München), Ger­many.