0

There's alot of questions on different forums [1] [2] [3] about this topic but none seem to provide a definitive answer. I've tried different combinations suggested in the various posts but I have yet to succeed.

My goal is to make compiled source code in a standalone tomcat (8) reloadable - just like the embedded tomcat reloads newly complied sources in e.g. spring-boot or Grails. There are a few constraints that I need to comply with:

  • No Grails or Spring-boot is available
  • No Maven or Gradle is available
  • The tomcat should read the exploded war file from an external location

To keep things simple I use a very simple JEE app with Spring MVC as POC for this before I move on to the real deal. The setup is as follows (for now):

  • Exploded war builds into directory target/exploded
  • Tomcat is setup with default settings except from Context.xmlwhere the two lines regarding WatchedResource are removed. Context is not set to reloadable="true".
  • The Tomcat server is run from within IntelliJ Idea (2016.3) like this: Tomcat run-config - deployment tab where the "exploded" folder points to the target described above. And the "Server" tab like this: enter image description here

The server starts up and the app is running fine. I then try to change some code, save it, and build a new exploded war file. I can see the class files change - but nothing is reloaded in tomcat.

Can anybody please elaborate? Is this approach even possible - in contrary to what many posts suggest? How is it possible in the embedded tomcat in e.g. Grails?

Community
  • 1
  • 1
Hoof
  • 1,738
  • 2
  • 17
  • 39
  • I could add that if reloadable=true is set in Context.xml and spring-loaded isn't provided as javaagent Tomcat actually picks up on class-changes. However the "reloading" time is much slower than a restart - even with this minimalistic app. – Hoof Jan 06 '17 at 08:47
  • Your definition of "reload' is a bit vague to me. Are you talking about hot-swapping classes rather than reloading the entire web application? If so - that's what the Java debugger does, Tomcat has little to do with that itself. – Gimby Jan 06 '17 at 09:09
  • It is exactly what I mean. Reloading the entire web-application is often very slow and you can come a long way with hot-swapping. Please elaborate on the last statement. Does this mean you cannot have hot-swapping in tomcat? – Hoof Jan 06 '17 at 09:11
  • You can, like any other application. As long as you start the server in debug mode from your IDE, it "should" just work. – Gimby Jan 06 '17 at 09:17
  • Well. The whole reason for this post is it doesn't :) At least not with the current "setup". – Hoof Jan 06 '17 at 09:56
  • So by that reflective reply, do you imply that you know how to start Tomcat with the JVM in debug mode, have tried that and got the same result? – Gimby Jan 06 '17 at 10:11
  • Unless there is more to in it than starting the run configuration in IDEA as Debug rather than Run - then yes. – Hoof Jan 06 '17 at 10:43

0 Answers0