First I've created an empty workbench for eclipse, added jboss server to the servers view and added a petclinic project from Spring samples, so that default ant task will build an application, pack it to the war file and deploy it to my local JBoss (that's how I usually configure the applications I work with), all in all - it looks like that:
So now the initeresting part of story - JavaRebel is the jvm agent which means that it is loaded with a JVM, receives its events and controls it magicly reloading changed classes on the fly. So after downloading it from zeroturnaround site you need to set up JBoss so that the virtual machine it is running on has this agent. For doing that you need to select JBoss server in Eclipse servers view (nobody likes running servers from a command line right? :)), double click on it, select "open launch configuration" and add JavaRebel arguments to the VM arguments:
-noverify -javaagent:/path/to/javarebel/lib/javarebel.jar -Drebel.dirs=/paths/to/class/folders/bin
/path/to/javarebel/lib/ - path to a folder where you unzipped javarebel library
/path/to/class/folders/bin - path where the compiled .class files bein placed (by default eclipse puts it to bin folder of your project)
It should look something like:
After that, make sure that the automatic publishing is switched on (the same screen where the "open launch configuration" link was). And you can launch JBoss. The first message in the server console should show that JavaRebel is successfully launched - e.g.
It will be a bit different if you do not have a license though :) The easiest way now to check if the voodoo has worked (for petclinic of course) is to comment out some validation from org.springframework.samples.petclinic.validation.OwnerValidator than go to http://localhost:8080/petclinic/addOwner.do and try to add an empty one - the commented out validation will not be triggered and you'll see the following message in the server console:
INFO [STDOUT] JavaRebel: Reloading class 'org.springframework.samples.petclinic.validation.OwnerValidator'.
That's really cool, JavaRebel's hot redeploy works in 95% of real life situations in my experience (yeah it does have limitations) but it does not really bug me.
The sad part of this story is JSP Weaver which is still unable to handle most of real life scriptlets (sometimes even the simple ones like <jsp:setproperty name="ad" property="language" value="<%= lang %>" /> are showstoppers for it). Scriptlets are evil, I know, sometimes though they are lesser evil and I really hope it will be fixed in the near future so I could change "make the situation better" to "solve the problem" and add a JSP Weaver installation chapter to this tutorial.

No comments:
Post a Comment