HowTo Making changes to the samples

From Lift

Jump to: navigation, search

The following instructions work for the svn version.

Making changes to the sample application using Maven and Jetty

  1. Open a first terminal
    #terminal 1
    cd liftweb/sites/example
    mvn clean jetty:run # add -U option the first time
    
  2. Open your browser to http://localhost:8888/
  3. edit the file (e.g., src/main/scala/net/liftweb/example/controller/Chat.scala)
  4. Open a second terminal window
    #terminal 2
    cd liftweb/sites/example
    mvn compile
    

    Instead of an explicit compile, which you have to issue everytime, you can also do 'mvn scala:cc'. This is going to send the scala compiler into continuous compilation mode. Error reporting might be sometimes a bit less precise though (showing you stale versions of the website, because the compilation failed but the compiler didnt say).

  5. wait 5s (Jetty will automatically restart itself with the new classes)
  6. you can reload the browser and your new code will be executing.

You will, however, lose all your session state and it takes a long time to go through this cycle.

Making changes to the sample application using Tomcat and Eclipse

<Context docBase="path_to_workspace/workspace/lift/example/src/main/webapp"
         path="/lift" reloadable="true" allowLinking='true'>
</Context>
  • cd into tomcat/bin and type: ./startup.sh and point your browser to http://localhost:8080/lift and you should see lift running
  • In Eclipse, make a change to one of the classes, wait 10 seconds for Tomcat to reload the context, reload the page and you'll see the change.

This sucks compared to Rails where I can make a change and reload

Yep. A big part of the problem is that Scala Actors interact badly with Tomcat's classloader. I'm working on the situation in two ways:

  1. Trying to get Actors to suspend themselves during the servlet context reload cycle. This may address the issue.
  2. Working on finding a JVM that supports better hot code replacement. Apparently, the IBM JVM allows changing class signatures and other fun stuff without requiring program reload. There's a bug running Scala under the IBM JVM, but the Scala team is looking into it.
Personal tools