Play2War 0.7 is out!

Damien published on
3 min

A major release

Despite of his version number, [Play2War](https://github.com/dlecan/play2-war-plugin( v0.7 is really a major release of this plugin for Play Framework 2, the famous productive web framework:

Servlet 2.5 containers can now be used to deploy your Play applications!

Servlet 2.5 containers means Tomcat 6, Jetty 7, ...

But this compatibility as a price: performances. They are worth than with Servlet 3.0, themselves worth than with native Play 2.

Two threads are indeed necessary to compute each request:

  • one for handling HTTP request
  • one for Akka asynchronous computing

Standard Java synchronization mechanisms (wait/notify) are then used to make theses threads work together. Of course, they are managed by threads pools, but synchronization has a cost. So if you need high performances and have to deploy WAR packages, please upgrade to a modern Servlet 3.0 container, such as Tomcat 7, Jetty 8, JBoss 7.x, Glassfish 3.x (not tested yet), ...

Don't forget to look at full Changelog.

Upgrade your project's configuration

Switching between Servlet 2.5 and 3.0 requires configuration, so you will need to upgrade to Play project to be compatible with Play2War 0.7.

Here is a typical Play2 project project/Build.scala using Play2war v0.6:

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "myproject"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      "com.github.play2war" %% "play2-war-core" % "0.6"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      resolvers += "Play2war plugins release" at "http://repository-play-war.forge.cloudbees.com/release/"
    )

}

Follow the next steps to upgrade it to play2War v0.7.

Remove Play2War core dependency

Dependency to Plat2War core is not necessary anymore. It will be automatically setup by the plugin.

Before:

val appDependencies = Seq(
  "com.github.play2war" %% "play2-war-core" % "0.6"
)

...

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  resolvers += "Play2war plugins release" at "http://repository-play-war.forge.cloudbees.com/release/"
)

So, remove it.

After:

val appDependencies = Seq(
  // Nothing or your other dependencies
)

...

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  // Nothing or your other settings
)

Update Play2War plugin version

As usual, update project/plugin.sbt:

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

Import Play2War SBT settings

...
import PlayProject._
import com.github.play2war.plugin._

Move all settings in a variable and add Play2War SBT settings to your project's settings

val appVersion      = "1.0-SNAPSHOT"

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

...

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

Configure servlet container version

val projectSettings = Play2WarPlugin.play2WarSettings ++ Seq(
  Play2WarKeys.servletVersion := "3.0"
  // Or Play2WarKeys.servletVersion := "2.5"
)

Final project file

import sbt._
import Keys._
import PlayProject._
import com.github.play2war.plugin._

object ApplicationBuild extends Build {

    val appName         = "myproject"
    val appVersion      = "1.0-SNAPSHOT"

    val projectSettings = Play2WarPlugin.play2WarSettings ++ Seq(
       Play2WarKeys.servletVersion := "3.0"
    )

    val appDependencies = Seq(
      // Nothing
    )

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

}

Package your application

Then, package your application as usual: sbt package (or play package).