JavaRebel-Compiling and Reloading Java Code on the fly. Looks like its ready for Development Primetime To Me
http://www.zeroturnaround.com/javarebel-demonstration-screencast/
http://www.zeroturnaround.com/blog/developing-in-exploded-format/
1. Install windows tool to create symbolic links on your hardrive.
http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx
To put on path copy junction.exe into C:/WINDOWS/system32
2. Open command prompt
C:\opt\tomcat\webapps>junction airweb C:\mavenWorkspace\airweb\src\main\webapp
Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com
Created: C:\opt\tomcat\webapps\airweb
Targetted at: C:\mavenWorkspace\airweb\src\main\webapp
3. Create a link from WEB-INF to the classes target directory. airweb/target/classes is eclipse is constantly compiling/building your project
C:\mavenWorkspace\airweb\src\main\webapp\WEB-INF>junction classes C:\mavenWorkspace\airweb\target\classes
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com
Targetted at: C:\mavenWorkspace\airweb\target\classes
C:\mavenWorkspace\airweb\src\main\webapp\WEB-INF\classes to svn:ignore list we don’t want this to have to be checked in in subversion
Where all dependencies are.
C:\opt\tomcat\webapps\airweb\WEB-INF>junction lib C:\mavenWorkspace\airweb\target\airweb\WEB-INF\lib
Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com
Created: C:\opt\tomcat\webapps\airweb\WEB-INF\lib
Targetted at: C:\mavenWorkspace\airweb\target\airweb\WEB-INF\lib
5. Remove reloadable and anitJARLocking and antiResourceLocking from web applications context.xml file.
This is very important and was not mentioned in the javarebel directions initially. Although I got the instruction from Jevgeni Kabanov from javarebel.
My Web Applications META-INF/context.xml file became
path="/airweb"
>
<!--
reloadable="true"
antiJARLocking="true"
removed based on javarebel Jevgeni Kabanov
-->
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
</Context>
6. Install JavaRebel
http://www.zeroturnaround.com/download/
Download
javarebel-1.1-M1a.zip
Copy javarebel.jar to C:\opt\tomcat\bin
These are the directions from java rebel
File: %TOMCAT_HOME%\bin\catalina.cmd (I don’t have these files in my tomcat instal as it was installed as a Windows Service)
Could not get the javarebel to install and work the way with catalina.bat cause I don’t have a catalina.bat file as they suggest above so I set the options in the Tomcat Service Manager.
I heard back from Jevgini Kabanov who suggested these options for tomcat.
If you use the windows service or system tray startup use the following parameters instead:
-Xverify:none -javaagent:javarebel.jar
I got some errors about opening javarebel.jar
-Xverify:none -javaagent:C:\opt\tomcat\bin\javarebel.jar
As a note when you run tomcat via
Start Menu -> Apache Tomcat 5.5 -> Configure Tomcat -> General Tab -> Start
I could not see the javarebel log message when starting from the Configure Tomcat in catalina.out or any of the other tomcat logs so I didn’t know if it was in fact loading javarebel or not. But when I changed my struts action classes the changes were picked up.
But when I open a cmd window in C:\opt\tomcat\bin and run tomcat I can see the
C:\opt\tomcat\bin>tomcat5
##########################################################
ZeroTurnaround JavaRebel 1.0.2
(c) Copyright Webmedia, Ltd, 2007. All rights reserved.
You are running JavaRebel evaluation license.
You have 15 days until the license expires.
You will see this notification until you obtain a
full license for your installation.
Visit www.javarebel.com for instructions on obtaining
a full license. If you wish to continue your evaluation
please e-mail to support@javarebel.com.
If you think you should not see this message contact
support@javarebel.com or check that you have your
license file in the same directory as the JAR file.
##########################################################
Note when this is working correctly your spring application context doesn’t have to reload if your just changing a struts action class. If you have reloadable=true in your Web Applications Context.xml it will reload the web app and the spring application context each time you make .class file change so make sure and follow step 5 above.
Also after I made action class changes many times tomcat did not crash.
Conclusion
I was on the brink of really trying to get down with learning another language such as groovy and another framework such as grails to get this type of dynamic reload capability. I have gotten php to work with quercus in the jvm as well. However I am not thrilled with php syntax although its very popular where I work.
In any case now I can continue with struts and not have to wait 1 minute plus everytime I make the most minute struts action class changes to do a full mvn install. This basically allow ones to develop in java with the ease of developing with a scripted language. I can see where groovy has some other advantages but at least for now I can get some massive increases in productivity while still using Spring, Struts and plain old Java instead of some other script based language.
- I.e. xml files changes: struts-config.xml, spring applicationContext.xml.
- Any dependency changes although there may be some way around this in the future.
And one last thing javarebel is for development purposes only, not such a bad thing since its purpose is really as a development aid.
|
One question is do you suggest runnning javarebel in production or only for development purposes. |
We suggest development only. JavaRebel has performance implications that might be unacceptable in production environment.
That said we might work on performance a bit later and get it to work in production. However it would be a different licensing policy, current licenses are development use only.
-Jevgini Kabanov
Re: JavaRebel-Compiling and Reloading Java Code on the fly. Ready for Primetime Yet?
Re: JavaRebel-Compiling and Reloading Java Code on the fly. Looks like its ready for Development Primetime To Me
I wanted to do this so I could continue to use maven to deploy my war and to remote machines (and maintain my dependencies still on my local) while trusting javarebel and eclipse to deploy the code on my local machine.
Basically I had to not deploy as I would have normally in my maven pom.xml. But I had to stop the webapp early on in the build, delete the lib symbolic link, let the maven do its compile and war process, then recreate the lib symbolic link and start the webapp.
If I didn't do this, I would have file locking problems. with jars in the WEB-INF/lib symbolically linked directory.
This seemed to work although I couldnt get many maven deploys off before retriggereing a PermGen OutOfMemory. Again this was only when I wanted to regenerate from the pom.xml a war file for deployment to a remote machine.
Re: JavaRebel-Compiling and Reloading Java Code on the fly. Looks like its ready for Development Primetime To Me
http://www.zeroturnaround.com/news/zero-turnaround-in-unexploded-development/
