Saturday, April 11, 2009

Eclipse, Maven, Java Rebel, and Hot Swap/Deployment

Hot Swap:
The ability to load the .class files dynamically at run-time

Hot Deployment:
The ability to deploy the .class files in Application/Web server at run-time

How do you do it?
Many solutions and no silver bullet yet!

One such solution follows....



Tools you need:

  1. Eclipse (tested with Ver. 3.4). Ensure WTP is installed
  2. FileSync eclipse plugin
    Download and install from http://andrei.gmxhome.de/filesync/index.html
  3. JBoss-Tools eclipse plugin
    Download and install from http://www.jboss.org/tools/download
    We need to configure JBoss server within Eclipse. The one provided by WTP is not advanced enough.
  4. Maven/Ant (if your project uses it)
    Any conventional directory structure is fine
  5. Java-Rebel .jar (license required)
    Download Trial version from http://www.zeroturnaround.com/javarebel/download/

The Key Enabler (...with some limitations):

The website also lists the comparison here.


Configuration Steps:

  1. Ensure all the plugins are installed
  2. Ensure eclipse is using JDK as Java runtime
  3. Enable JBoss Server View
  4. Configure JBoss Server ...including Java-Rebel settings
  5. Checkout code using SVN and create your default Java project. Assuming Maven structure, build once using console and charge-up your local .m2 repository
  6. Create empty eclipse WTP Dynamic Web Project
  7. Link src and resources folder in WTP_Project to the above Maven-Java project
  8. Copy ‘lib’ folder from ear/target folder into WEB-INF/lib in WTP project
  9. FileSync web/src/main/webapp to WTP_Project/WebContent folder
  10. Set output path for your WTP_Project as WEB-INF/classes
  11. Fire up your server from within Eclipse
  12. Any code changes you’ll make are in your Maven project

JBoss Server View settings:

  1. Automatically publish set to 0 sec
  2. Server start timeout increased >300s
  3. Custom Deploy directories
  4. JMX admin password

JBoss Launch Configuration VM arguments in JBoss Server View:

Dprogram.name="JBossTools JBoss 4.0 Runtime" -Xms256m -Xmx512m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs="C:/NOSCAN/jboss-4.0.5/lib/endorsed" -noverify -javaagent:C:/javarebel-2.0/javarebel.jar -Drebel.spring_plugin=true -Drebel.aspectj_plugin=true

The BOTTOM LINE

  • No ‘build’ segment
    ◦Code in Eclipse is always “Build Automatically”
  • No ‘deploy’ segment
    ◦If you abide by the Java-rebel capabilities
  • Rapid feedback (including Spring IoC)
    ◦All spring layers (controller, command, dao, Beans)
  • Original code base not affected by Eclipse WTP project
  • Occasional restart of Jboss within Eclipse, when
    ◦Redefining Interface
    ◦Updating ‘static’ block
  • No JBoss Crashing in Eclipse with JBoss Tools plugin…so far.

ENJOY.....and smart coding...