I would like to setup eclipse and tomcat in an integrated fashion such that changes to my JSPs and servlets(if possible) are reflected immedietely without requiring a deployment.
Ok, this is one of those questions that has plenty of answers all across the internet but they all seem different. (use Sysdeo plugin, use JBOss plugin, do stuff with an outdated Eclipse, use MyEclipse instead etc.) and I couldn't find 1 definitive resource to refer to. So for my benefit, what is the simplest and most recommended procedure to set this up ?
This assumes I have eclipse and tomcat running independently. I actually have managed to integrate them in a non-hot deploy fashion using instructions here : http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html
Eclipse version Version: 3.4.2 (Ganymede) Tomcat v6.0.20
Disclaimer: I'm just a happy customer, I don't work for Zero Turnaround and I'm not in any way affiliated with them.
Check out JRebel - it allows you to code without web application restarts. It basically works by instrumenting your classes and adapting their changes. It handles many more cases than hot deploy, including:
It's commercial, ( pricing details, $550/year as of June 2018 ) , and it has a lots of plugins for third party frameworks, including:
You get a free trial quite painlessly - I suggest you give it a shot.
In Eclipse, click on the Project in the top menu and make sure “Build Automatically” is selected. This fixed my problem. I was running Eclipse with Tomcat using my workspace metadata. I was also running Maven in a Dynamic Web Module project. To verify, add your application to Tomcat. Start Tomcat from within Eclipse. Make sure your application is deployed and running. Open the Console tab in Eclipse. Make a change in your application. After a couple of seconds you should see your change getting automatically built and deployed to Tomcat.
Why not use an integrated tomcat server from with in eclipse if this is just for development? You can configure servers under window->preferences. Once it's configured if you have a jsp called page.jsp you can right click it and select run on server. Under preferences->general->Web browser you can chose weather to use the built in browser or an external one. Make some changes to your jsp, save, and refresh your page from the browser. The changes will be automatically reflected once you save and refresh your browser.
I've managed to get this working on my development environment using the Spring Loaded JVM agent. While I do develop Spring web applications, that project's description does mention that it is
Using the following setup, I was able to get changes to publish automatically to an attached Tomcat instance (the usual Eclipse WTP method). I'm using Spring Tool Suite 3.7.3 based off Eclipse Mars.2 (4.5.2).
-javaagent:/path/to/downloaded/springloaded-1.2.5.RELEASE.jar -noverify
.class
files, configure the-Dspringloaded=watchJars=
VM argument per this issue's comments.Start the server and publish Dynamic Web Application projects to it as usual. Again, I was able to test this with Spring web applications. For example, modifying code, adding/subtracting methods, etc. in @Controller classes were applied nearly instantly after I save the file and Eclipse builds and publish the changed class. Lastly, the FAQ section of the Spring Loaded project did mention a few cases where things won't reload, so those would require a restart of the server/application. But those exceptions are much less frequent.
One more note: This does NOT work with the embedded Pivotal tc Server or VMware vFabric tc Server that comes with STS. For those servers, there is a "Enable Java Agent-based reloading (experimental)" option, but that uses the older 1.2.0 release of Spring Loaded, which did not work for me.