Sunday, May 8, 2011

Learning Scala - Code Update without Redeployment via JRebel

Scala Developer entitles to free license from JRebel, just request it from ZeroTurnaround (, the license will be emailed to you in minutes. You'll need to download and install JRebel as well.

Having done so, you are only 2 steps away from code update without redeployment.

Step 1
Changed your sbt launch script, I have changed mine to:-

java -Xmx1512M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -noverify -javaagent:/opt/ZeroTurnaround/JRebel/jrebel.jar -jar /opt/sbt/sbt-launch-0.7.5.jar "$@"

Note that I installed my sbt jar in /opt/sbt/ and JRebel in /opt/ZeroTurnaround/JRebel/.

Step 2
Change your Web Project build class:-

import sbt._
class WebAppBuild(info: ProjectInfo) extends DefaultWebProject(info) {

val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.14" % "test"
val servletApi = "javax.servlet" % "servlet-api" % "2.5"

override def jettyWebappPath = webappPath
override def scanDirectories = Nil

That's all for the setup, now you can launch sbt in your project directory and test:-

~ prepare-webapp

Go ahead and change your Servlet source file, upon saving, you can refresh your web browser to see your changes immediately, without the need to redeploy the whole web app.

No comments:

Post a Comment