Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having to restart tomcat whenever you make a change

Tags:

Is there a way around having to restart tomcat every time a small change is made in java code?

like image 784
nuaavee Avatar asked Dec 06 '10 22:12

nuaavee


People also ask

Why do I need to restart Tomcat?

Restarting the Tomcat server is also a way to stop and restart your applications, which allows elements such as web. xml files to be reloaded (although there are ways of reloading these files without stopping the server).

Why Tomcat is getting stopped automatically?

try to clean your elipse projects because you could have tried to add another server which used port 8080 then when you try to execute the tomcat server externally that defaulty uses port 8080 the tomcat server automatically shutdowns after cleaning the project copy the new war file and paste it in bin it works fine ...

Why Tomcat does not require restart when JSP is changed?

It is because Tomcat is capable of adding/modifying classpath to Web Application classloader at runtime . Tomcat will be having their custom Classloader implementation which allows them to add the classpaths at runtime .

How often should Tomcat be restarted?

Under certain conditions, Tomcat may fail heartbeats and once this happens 3 consecutive times, the service will restart. If the service restarts 8 times in 4 hours, this alert is raised. For clusters with AOS versions below 5.10. 11, 5.15.


2 Answers

Set reloadable attribute of <Context> element in context.xml to true.

<Context reloadable="true"> 

Then Tomcat will monitor changes in /WEB-INF/classes and /WEB-INF/lib and reload whenever appropriate.

If you're using an IDE, this is configureable as server setting as well. Here's how it look like in Eclipse:

alt text

like image 106
BalusC Avatar answered Sep 19 '22 12:09

BalusC


Check out Jrebel. It detects the code changes, compiles and deploys the war automatically, without having to restart the server. It saves a lot of time and improves the productivity.

like image 28
Vanchinathan Chandrasekaran Avatar answered Sep 17 '22 12:09

Vanchinathan Chandrasekaran