2

I can see that sbt-revolver is set up and running on spray can but my changes don't appear when I make a request to a service.

You can see in the logs jrebel is doing its thing:

    [success] Total time: 1 s, completed Feb 24, 2013 3:13:18 AM
app: [INFO] [02/24/2013 03:13:19.497] [com-example-Boot-spray.io.io-bridge-dispatcher-7] [akka://com-example-Boot/user/io-bridge] akka://com-example-Boot/user/io-bridge started
app: [INFO] [02/24/2013 03:13:19.851] [com-example-Boot-akka.actor.default-dispatcher-2] [akka://com-example-Boot/user/http-server] akka://com-example-Boot/user/http-server started on localhost/127.0.0.1:9000
>                 ~products
[success] Total time: 0 s, completed Feb 24, 2013 3:13:23 AM
1. Waiting for source changes... (press enter to interrupt)
[info] Compiling 1 Scala source to /Users/tripled153/Development/src/Foundationv2/spray-template/target/scala-2.10/classes...
[success] Total time: 2 s, completed Feb 24, 2013 3:13:33 AM
2. Waiting for source changes... (press enter to interrupt)

But changing the message in my trait doesn't appear on refresh.

package com.example

import akka.actor.Actor
import spray.routing._
import spray.http._
import MediaTypes._


// we don't implement our route structure directly in the service actor because
// we want to be able to test it independently, without having to spin up an actor
class MyServiceActor extends Actor with MyService {

  // the HttpService trait defines only one abstract member, which
  // connects the services environment to the enclosing actor or test
  def actorRefFactory = context

  // this actor only runs our route, but you could add
  // other things here, like request stream processing
  // or timeout handling
  def receive = runRoute(myRoute)
}


// this trait defines our service behavior independently from the service actor
trait MyService extends HttpService {

  val myRoute =
    path("") {
      get {
        respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here
          complete {
            <html>
              <body>
                <h1>Say hello to <i>spray-routing</i> on <i>spray-can</i>!</h1>
              </body>
            </html>
          }
        }
      }
    }

}

This is built on the spray can example which has revolver set up on it. https://github.com/spray/spray-template

JasonG
  • 5,794
  • 4
  • 39
  • 67
  • It's hard to say what's wrong with your setup. You can make example project on github and I'll check it. – 4e6 Feb 24 '13 at 08:56
  • 1
    Project is the spray-template project here: https://github.com/spray/spray-template/ – JasonG Feb 24 '13 at 10:09
  • 1
    It works for me. Interesting... Maybe it's an issue with jrebel license activation. Can you see output from jrebel on `re-start`, like `Contacting myJRebel server ..` with information about version, license, etc? – 4e6 Feb 24 '13 at 12:13
  • Hey man - good call - I have the jrebel activation code but not the license. There appears to be some documentation problems on the zt site. It says to take the activation code and post it into the jrebel plugin in your ide but there is nowhere in the intellij ide that the activation code goes so I'm stuck trying to figure out how to activate. The documentation for intellij on zt shows that you take the license key and post it into the IDE but does not show how to deal with the activation code... There is no configuration wizard or whatever in the intellij ide. – JasonG Feb 24 '13 at 22:05
  • BTW using SBT I don't need any ide plugin anyways so I'm not sure why they don't take into account that case. Mind you it is free so that's pretty awesome - I almost bought a license the other day for java development anyways :P – JasonG Feb 24 '13 at 22:06
  • 1
    Yes, it feels like docs are scattered across their site. So, all information about license, plan, etc. resides at [my.jrebel.com](http://my.jrebel.com). And you can setup jrebel through [jrebel plugin](http://zeroturnaround.com/software/jrebel/download/) for you IDE. Also there is activation script in [jrebel-noinstall](http://zeroturnaround.com/software/jrebel/download/prev-releases/) distribution. – 4e6 Feb 25 '13 at 06:48
  • You are right, the JRebel headless license install was a pain, and I can't remember just now how I got it to work in the end. Did you manage? – jrudolph Mar 02 '13 at 08:54
  • I'm doing some architecture migration (to scalatra as it seems the right tool for the job). I'll try again shortly as there is jrebel integration on scalatra too. https://github.com/scalatra/scalatra-jrebel-plugin – JasonG Mar 05 '13 at 16:40

3 Answers3

2

The problem is that the route is built only once when the service starts. Try wrapping the complete route with the dynamic directive to rebuild it for every request.

EDIT: See this mailing list thread on the topic.

jrudolph
  • 8,307
  • 4
  • 32
  • 50
1

Please make sure you've set JREBEL_PATH to your copy of jrebel.jar's absolute path.

Kaid
  • 26
  • 1
  • 4
0

I was using re-start command and JRebel was NOT catching any change. Then I did this:

Start sbt in one terminal session and run the start command (this is the start, not the re-start command)

Open another terminal session and run sbt with the command ~compile.

And that's it, running SBT in two separate windows with the start and the ~compile commands will do the trick.

Obviously JRebel must be active and with a valid license.

Remeber that JRebel does not reload absolute everything when the source code had changed. Take special attention to cached values like cached routes or data. In that case, you need to code a simple trick to force cache reload, could be time based or just quering a file lock or even a simple property in a reloadable class that JRebel in effect will refresh.

Carlos Saltos
  • 1,385
  • 15
  • 15