Configuring Tomcat server to use updated class files without restarting the server

Posted on 2006-06-19
Last Modified: 2013-11-24
Is there any way to configure Tomcat to use updated class files with restarting the server? The main point is that if I create a new version of the class file and then FTP this version to the correct directory on the server, the server apparently continues to use the older version of the class file. One way to solve this is by refreshing the server. However, we do not want to refresh the server as this may cause complications for clients who are already connected. Is there any way to accomplish this without refreshing the server?
Question by:pr12
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
LVL 16

Expert Comment

ID: 16939135
As far as I know, you need to restart Tomcat. If it is JSP files then you may not need to restart Tomcat.

One way you can do is to design your architecture as cluster where multiple Tomcat servers are involved. Hence if one Tomcat is shut down, the rest of the servers are not affected. Then once the server has been updated, you can put it back online and restart the rest of the servers.


Expert Comment

ID: 16940928
Its not possible according to my knowledge..U need to restart tomcat fora single line or word of  change in any jsp file.  Such a facility is available in Weblogic server which is third party compenent that helps to detect changed files to avoide  restart.
But no such facility available in tomcat yet.

Expert Comment

ID: 16941094
You need to turn on Servlet Reloading on your Tomcat.
[While the below works, for Tomcat 4 another answer is simply to add the attribute reloadable="true" to the Context element for that webapp. Sometimes you don't want all contexts to be reloadable.]

To turn on servlet reloading, edit install_dir/conf/server.xml and add a DefaultContext subelement to the main Service element and supply true for the reloadable attribute. The easiest way to do this is to find the following comment:

<!-- Define properties for each web application. This is only needed if you want to set non-default properties, or have web application document roots in places other than the virtual host's appBase directory. -->

and insert the following line just below it: <DefaultContext reloadable="true"/>

Be sure to make a backup copy of server.xml before making the above change.

In addition, in case you wish to specify reloading after a certain interval add the following attributes also to the server.xml:
<Loader className="org.apache.catalina.loader.WebappLoader" loaderClass="org.apache.catalina.loader.WebappClassLoader" checkInterval="3" />

By default reload takes place every 15 seconds. The above object should be placed with in the Context element of your web-application.
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.


Author Comment

ID: 16942444
Thanks for all the replies. They are very useful. Yagantappa, the technique you have listed, is it useful for reloading the servlets alone or can I use for normal java classes as well?

Accepted Solution

Yagantappa earned 150 total points
ID: 16942780
It should work for all java class files.

Author Comment

ID: 16945434
I have it working, thanks for your help.
LVL 16

Expert Comment

ID: 16948174

I really learn something new too :)


Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question