Friday, May 22, 2009

Exploded Hot deployment with Maven and Java Rebel outside IDE

Here is another way, more simpler than the one shown in my earlier post.

The following configuration works with JBoss. Adjust accordingly with your app server. Assuming you have all the required plugins as laid out in the earlier post.

Configuration Steps

  1. In the JBoss deploy folder, create any folder with folder name ending with .war (e.g. myProject.war)
  2. Setup your IDE environment with Maven plugin and run the project as usual.
  3. Make sure your project compiles and generates a .ear or .war file in the default Maven target folder structure. Extract the lib folder as it contains all the dependencies of your project.
  4. Inside the myProject.war, create a WEB-INF folder and paste that lib folder. This is the only manual step that requires due attention. Rest is just configuration and synchronization!
  5. Configure Java Rebel as laid out in the earlier post. However, put the Java Rebel settings in JBossDir/bin/run.bat file.
  6. Ensure the classpath of your Maven project in your IDE has all the Java paths and resources folders. Also ensure that the output directory for your project classpath is myProject->target->classes folder
  7. Using FileSync plugin, synchronize two folders (from within Eclipse)
    • MavenProject->web->src->main->webapp to deployDir->myproject.war folder
    • MavenProject->target->classes to deployDir->myproject.war->WEB-INF->classes
  8. That's it.
  9. Continue coding, run JBoss in background from the console using run.bat file in JBoss/bin directory. Save your file (.java, .js, .ftl, .vm, .xml) and check it immediately in your browser.

Smart Coding....

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...