Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change in configuration/setting without restarting Tomcat

Ideally what I want to be able to do is load in a fresh copy of the config if a change is detected so that if it is updated in the DB, it gets fetched and updated in the application without a restart.

I tried to add autodeploy = true inside host, server.xml and reloadable = true inside context.xml.But none of this worked.

Is there any other solution for this. Iam using eclipse IDE and my sever is Tomcat.

I read adding inside context will help for this.

<Context reloadable="true">

    <!-- Default set of monitored resources -->
    <WatchedResource>Config/Design/configs/globalconfig</WatchedResource>

But this one still din't help me.Am I giving the path in wrong way or something?I got this from the following link https://www.mulesoft.com/tcat/tomcat-reload

Edited Besides I tried with the auto reload on module, disabled and enabled as well. And also noting one more thing here I don't want to use JRebel.

like image 649
Lilac Avatar asked Nov 06 '19 16:11

Lilac


2 Answers

If I go by the heading of the question

change in configuration/setting without restarting Tomcat

I would agree with Jomcy Johny, that the design approach perhaps need to be reviewed. In continuation to the above comment, perhaps you should consider keeping the configuration outside of the container. There are many way of achieving the same, one possible direction is with Apache Zookeeper.

On the side note, the path mentioned in the Mule document is generally of form 'WEB-INF/x/yz' or '/Dir0/config.file'.

like image 123
Ironluca Avatar answered Sep 24 '22 00:09

Ironluca


It is possible to deploy web applications to a running Tomcat server.

If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration.

autoDeploy set to "true" and a running Tomcat allows for:

  • Deployment of .WAR files copied into the Host appBase.
  • Deployment of exploded web applications which are copied into the Host appBase.
  • Re-deployment of a web application which has already been deployed from a .WAR when the new .WAR is provided. In this case the exploded web application is removed, and the .WAR is expanded again. Note that the explosion will not occur if the Host is configured so that .WARs are not exploded with a unpackWARs attribute set to "false", in which case the web application will be simply redeployed as a compressed archive.
  • Re-deployment of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated. Re-deployment of a web application if the Context Descriptor file from which the web application has been deployed is updated.
  • Re-deployment of a web application if a Context Descriptor file (with a filename corresponding to the Context path of the previously deployed web application) is added to the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory.
  • Undeployment of a web application if its document base (docBase) is deleted. Note that on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application

Above is a snippet from Apache tomcat And also most of the general idea about hot deployment I gained from hot deploy

like image 31
django Avatar answered Sep 22 '22 00:09

django