Anyone know how to get JRebel working in SBT Console in Intellij IDEA?

344 views
Skip to first unread message

Kenneth McDonald

unread,
Jul 22, 2011, 9:49:40 PM7/22/11
to lif...@googlegroups.com
To phrase that more correctly, does anyone know how to get JRebel working when launching a Lift application via the SBT-Idea console? The JRebel folks were nice enough to give me an OSS license because I'm trying to develop a wiki using Scala, and it would be great to be able to use it :-)

There is a JRebel plugin for IntelliJ which would probably work great if I could ever get IDEA and my Scala libs in synch, but for some reason IDEA on my system is really bad at recognizing and adapting to the config that SBT sets up for my projects. If I have to, I'll try to go that route, but I don't think I've ever managed to get IDEA to agree that absolutely everything is hunky dory on code that compiles and runs under SBT just fine. (Even in spite of this, IDEA is a pretty good editor, though Eclipse does seem to be making up for lost time.)

Anyway, if you know how to get JRebel to work in this situation, I'd appreciate a note.


Thanks,
Ken

ejc

unread,
Jul 23, 2011, 1:54:42 AM7/23/11
to lif...@googlegroups.com
I've been using exactly this setup. I don't have a computer handy
with everything setup, but I'll see if I can describe it well enough.

First of all, I'm using the latest versions of everything:

IDEA 10.5.1
sbt 0.10.1
scala 2.9.0-1
Lift 2.4M-3
Jrebel 4.0.2

I assume you already have the scala, SBT, and Jrebel plugins installed
in IDEA. In IDEA, open the settings window and select the 'SBT'
settings. Set VM parameters to (in place of $HOME I have the full
path, don't know that $HOME will work):

-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M
-noverify -javaagent:$HOME/jrebel/jrebel.jar -jar
$HOME/bin/sbt-launcher.jar

Next you'll need to set up the sbt plugin that generates Idea configs.
Start by creating $HOME/.sbt/plugins/project/Build.scala

$cat ~/.sbt/plugins/project/Build.scala

import sbt._

object MyPlugins extends Build {
lazy val root = Project("root", file(".")) dependsOn
(uri("git://github.com/ijuma/sbt-idea.git#sbt-0.10"))
}

according to https://github.com/ijuma/sbt-idea/tree/sbt-0.10

Then change to your project directory and start sbt from the command
line. It will churn for a while and build the plugin you just
specified.
Once it's done, type

update
gen-idea

It should generate the Idea config files so Idea will recognize your
project. Open it with Idea.

You should be able to start up the sbt console from Idea and run you
app from there.

One note, I am having some trouble getting it working on Windows, but
it does work on unix-y systems.

Hopefully this is at least semi-coherent and helpful.

Thanks,
Eric

> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liftweb/-/SEuomyJ6Jb8J.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>

Kenneth McDonald

unread,
Jul 23, 2011, 4:29:38 PM7/23/11
to lif...@googlegroups.com
Hi Eric. Very helpful, but of course I'm having a few problems. For the project I'm using older versions of everything except JRebel. I also deviated from your instructions in setting up the project for IDEA, because I installed the sbt-idea plugin a long time ago as a processor in IDEA, so to get a project dir ready, I just go into it, type "sbt" and fill in the required forms, and then type "idea".

So my VM params look like: -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -noverify -javaagent:/Applications/bin/JRebel/jrebel.jar  -jar /Applications/bin/sbt-launch.jar

and the problem I'm having trying to start up sbt is:

...bunch of stuff indicating JRebel is starting up...

#############################################################

Exception in thread "main" java.lang.NoClassDefFoundError: 
Caused by: java.lang.ClassNotFoundException: 
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

That's not an error that means much to me--I'm not even sure of the name of the class that it was looking for but couldn't find. Can you shed any light on the matter?

This is on OS X, by the way.


Thanks,
Ken

ejc

unread,
Jul 23, 2011, 9:06:36 PM7/23/11
to lif...@googlegroups.com
It would help if I gave you the correct VM params :-) I should know
better than to fly blind late a night... The correct params are:

-XX:+CMSClassUnloadingEnabled -Xss2M -Xmx512M -XX:MaxPermSize=256M
-noverify -javaagent:/Applications/bin/JRebel/jrebel.jar

the -jar gets added by the plugin and /Applications/bin/sbt-launch.jar
is from the 'SBT launcher JAR file' setting.

Hope that helps,
Eric

> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/liftweb/-/9wWK7hfwSysJ.

Naftoli Gugenheim

unread,
Jul 23, 2011, 11:59:49 PM7/23/11
to lif...@googlegroups.com


On Fri, Jul 22, 2011 at 9:49 PM, Kenneth McDonald <ykke...@gmail.com> wrote:
to give me an OSS license

There's also a free license for scala use.

Kenneth McDonald

unread,
Jul 24, 2011, 12:10:05 AM7/24/11
to lif...@googlegroups.com
Yep. However, the Scala license will _not_ work with Java class files--while the OSS license gives me the flexibility to use an existing Java package if I decide to do so.

Cheers,
Ken 

Antonio Salazar Cardozo

unread,
Jul 24, 2011, 3:25:43 PM7/24/11
to lif...@googlegroups.com
Though note that `not work' in this case means `not hot swap'. Which is to say, the Scala license means JRebel will only hot swap Scala class files.
So this is only a problem if you want to integrate an existing Java package's source into your source; otherwise, you can restart in the rare case where
you upgrade the Java package as a dependency.
Thanks,
Antonio

Sergey Trofimov

unread,
Jul 25, 2011, 2:11:28 AM7/25/11
to lif...@googlegroups.com
Does JRebel reload jetty when HTML or other non-Scala files are changed?

--
Sergey

Naftoli Gugenheim

unread,
Jul 25, 2011, 2:22:27 AM7/25/11
to lif...@googlegroups.com
JRebel doesn't reload jetty. prepare-webapp copies all the files to where jetty serves them from. When it comes to .class files, that is not enough because the JVM keeps them in memory. JRebel's job is to check if they were updated and replace the in-memory class data.

So html files will update even without JRebel.


--
You received this message because you are subscribed to the Google Groups "Lift" group.
To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/Zou82fHC0HYJ.
Reply all
Reply to author
Forward
0 new messages