RSS feed
All(28) Eclipse(4) Java(5) JDBC(5) JSP(3) Maven(7) Personal (1) Spring(3) Tomcat(5)
<< Avoiding Connection Leakage and Boiler Plate Code with Spring JdbcTemplate | Home | Eclipse Performance - JVM Setttings and Turning Paging Off in Windows >>

JavaRebel-Compiling and Reloading Java Code on the fly. Looks like its ready for Development Primetime To Me

Read On for the details on developing in exploded format

For reference

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

screenshot
 

C:\mavenWorkspace\airweb\src\main\webapp\WEB-INF>junction classes C:\mavenWorkspace\airweb\target\classes

 Junction v1.05 - Windows junction creator and reparse point viewer

Copyright (C) 2000-2007 Mark Russinovich

Systems Internals - http://www.sysinternals.com

 Created: C:\mavenWorkspace\airweb\src\main\webapp\WEB-INF\classes

Targetted at: C:\mavenWorkspace\airweb\target\classes

 C:\mavenWorkspace\airweb\src\main\webapp\WEB-INF>

 Make sure to add the linked in directory

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

 4. Create a link from WEB-INF to the lib target directory. airweb/target/lib

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

 <Context crossContext="true" debug="5"

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.

 My JVM  would not recognize the –noverify option that the javarebel instructions intially referred to.

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

I changed this to aboslute file location and I stopped getting those errors.

-Xverify:none -javaagent:C:\opt\tomcat\bin\javarebel.jar

screenshot

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.

 There are certain application changes that require full web application reload.

  1. I.e. xml files changes: struts-config.xml, spring applicationContext.xml.
  2. 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. See this email from Jevgeni->

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

Im really looking forward to using this. 

 

Tags :


Re: JavaRebel-Compiling and Reloading Java Code on the fly. Ready for Primetime Yet?

The reason that JavaRebel crashed was most probably the lacking of the -noverify option, which it requires. You can substitute it in Tomcat (which calls the jvm.dll directly on Windows) by using -Xverify:none.

Re: JavaRebel-Compiling and Reloading Java Code on the fly. Ready for Primetime Yet?

I also added the -Xverify:none to the installation options for Tomcat: http://www.zeroturnaround.com/javarebel/installation/.

Re: JavaRebel-Compiling and Reloading Java Code on the fly. Looks like its ready for Development Primetime To Me

Another note in order to get javrebel/windows/tomcat and maven working nicely i had to do some interesting stuff in my pom.xml.

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

Zero Turnarounds Java Rebel now has unexploded format development, This doesnt require monkeying around with any symbolic links and is much more tomcat , maven , eclipse friendly I think. I woudl definitely check it out.

http://www.zeroturnaround.com/news/zero-turnaround-in-unexploded-development/

Add a comment Send a TrackBack