Wednesday, January 15, 2014

How to deploy a web application outside Tomcat and use JRebel to prevent restarts to see the code changes

There are 2 things I feel are slowing me down while building java applications. And 1st one is copying the web applications into webapps folder of the Tomcat.After I make changes to the java code I have to compile the code, make the war file and deploy it in the webapps folder of Tomcat. This slows down the development process and java developers just wish they can avoid this. There are couple of ways to avoid this.

Deploying web application outside the Tomcat WebApps folder

One of the way is to deploy the war outside the webapp of the Tomcat which is described below.

Move to the following location in your Tomcat installation folder.

<Tomcat Home>--> conf --> Catalina --> localhost

In this folder create a xml with the name of your web application.Say I want my service to be 'MyApp1' then create a 'MyApp1.xml' in the above path.

Add the below content in the file created.

<Context path="/MyApp1" docBase="C:\Users\vkiran\Desktop\MyApp1\war" reloadable="true">

Your are defining the  context name for your application and providing a location which has your compiled web application for the Tomcat to load. When you start the Tomcat, Tomcat will load your web application 'MyApp1' from  'C:\Users\vkiran\Desktop\MyApp1\war' location. So you don't need to copy your war file to Tomcat webapp folder every time.


But you still need to compile your code and restart Tomcat for every code change you make.Redeploying the application for every small change in the code is one of things I hate  most in Java. JRebel provides a relief from this constant recompiling mess. JRebel reloads the classes without redeploying the application and so you can view your code changes without restarting the applications.It supports most of the Java Frameworks, has plugins for all major java IDE's and is a great productivity tool for java developers. It is a paid tool and a trial version can be downloaded from here.

Download and extract the zip file.

In Tomcat --> bin folder, create a 'catalina-jrebel.bat' file with the following content.

@echo off
set JAVA_OPTS=-javaagent:[path/to/]jrebel.jar %JAVA_OPTS%
call "%~dp0\catalina.bat" %*

The jrebel.jar is available in the extracted zip file. Replace '[path/to/]' in the above script with the path to the jrebel folder on your system.

If you want to launch your Tomcat with JRebel enabled, run this catalina-jrebel.bat.

catalina-jrebel.bat run

If you configured jrebel correctly on Tomcat, you will see some thing similar on your command prompt when you start the Tomcat. Some information on where the jrebel log file goes, what is the version, statistics on the time saved using jrebel and license etc.

Also the command prompt will display the list of frameworks supported by jrebel but not used/enabled in your application and if there are any updates to jRebel.

If Tomcat is run as a service in your development environment, select 'Monitor Tomcat' from your Run --> Programs or double click on the Tomcat icon in the system tray. Then insert the below parameter in Java --> Java Options


Replace [path/to/] with the path to the jrebel folder on your system.

If you launch the Tomcat with JRebel on, you need not restart Tomcat to see your code changes. Just refresh your browser or test the functionality without restarting the application. JRebel reloads the modified classes and so you can concentrate on your code changes without getting distracted by the continuous re-deployments.


  1. Hello...thank you for good you have a tutorial in video or youtube?thank you...

  2. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work Webdesign bureau

  3. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. best web development usa

  4. Along these lines, the main genuine downside for a web improvement firm is that they are typically pricey. On the other hand, cost is relative and greater organizations like to work with greater organizations. Web Design Curriculum

  5. We have sell some products of different custom is very useful and very low price please visits this site thanks and please share this post with your friends. freelance web designer peter

  6. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. Web Designing

  7. This is the next step beyond a freelance professional. The web design company offers the "whole show". They provide real project management and have pulled together a team of web experts to get a wider range of jobs done.Web Designer

  8. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Digital marketing company

  9. PHP is very outstanding and perceived programming language for custom website advancement with its completely useful scripting language.Webdesign

  10. If one wants to maintain good working relationships then, edifying clients are one of the wisest ways. Web designing is an essential fragment of the service-industry and thus follows the same rules. Webdesign

  11. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. web design company lakeland

  12. Really appreciate this wonderful post that you have provided for us. Very informatory and important blog for those who want to design and develop a website.This is such a great resource that you are providing. Thank You for sharing this tip which is very necessary in latest strategy. Web design business

  13. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work ui vs ux