Link to home
Start Free TrialLog in
Avatar of pr12
pr12

asked on

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

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?
Avatar of suprapto45
suprapto45
Flag of Singapore image

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.

David
Avatar of kaliyugkaarjun
kaliyugkaarjun

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.
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.
Avatar of pr12

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Yagantappa
Yagantappa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pr12

ASKER

I have it working, thanks for your help.
Wow,

I really learn something new too :)

David