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">
</Context>

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.

JRebel


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 jrebel-5.5-nosetup.zip 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

-javaagent:[path/to/]jrebel.jar

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.

30 comments:

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

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

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

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

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

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

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

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

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

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

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

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

    ReplyDelete
  13. Friend, this web site might be fabolous, i just like it. design

    ReplyDelete
  14. 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. ui/ux design

    ReplyDelete
  15. In order to minimize the cost of the set up, the website designer should be equipped with predefined web templates. Having this feature in your armory, you don't need to go hog-wild with the designs for the reason that you are not designing a website by tinkering.Digital Marketing Company in Singapore

    ReplyDelete
  16. Along these lines, a site page ought to be planned remembering, the client and business needs.Webdesign

    ReplyDelete
  17. Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. web developers

    ReplyDelete
  18. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. website design

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. He made a site that had the scale that would have been required. smm panel

    ReplyDelete
  21. I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. web design in Switzerland

    ReplyDelete
  22. Today, one needs to dig deep into a website and identify issues that will greatly affect how your website ranks for keywords and phrases and how your website compares with your competition. Trust Pilot Scraper

    ReplyDelete
  23. Do they actualize the SEO Web advertising administrations to improve online business?SEO lead generation

    ReplyDelete
  24. When you have the articles prepared, join with significant article registries like EzineArticles.com. For this specific site, you can at first submit 10 articles in the event that you have an essential record, when those articles are support, your status is updated so you can submit more. email accounts list

    ReplyDelete
  25. Yet, ensure that you additionally have the opportunity to sign in and share a portion of the posts and substance from others in the social media destinations who likewise share your posts. Set aside effort for some online discussions also. SMM Panel

    ReplyDelete

  26. I don't think it is reasonable for portray the business in general without sorting out what's up with it and how SEO organizations can conquer it. https://www.sempris.be/webdesign-hasselt-webdesigner-hasselt/

    ReplyDelete
  27. To boost benefits, it is extremely regular for SEO organizations to purchase mass connections from India, joins on spam/scrubber sites, or sell huge index accommodation bundles. It is likewise regular for SEO organizations to put enormous measures of the agreement into inbound connecting to compensate for the low quality of the site enhancement. Webdesign-seo-antwerpen.be

    ReplyDelete
  28. In rundown while picking a custom CMS web design, spending plan however much quality that you can bear, use due perseverance in choosing your design group, and put away progressing time or cash for future advancement of your design. Wat is leadgeneratie

    ReplyDelete
  29. If you are looking for more information about flat rate locksmith Las Vegas check that right away. pay monthly web design

    ReplyDelete