Integrating Tomcat and Eclipse as a Hot-Deploy Environment

How to hot deploy code in Tomcat running in debug mode

We can make some changes in tomcat to support hot deploy, there can be different ways to achieve that.

One of the simplest way is making change in tomcat setting in eclipse/STS,

  • Double click on the Tomcat plugin, refer to publishing tab, make sure "Automatically publish when resources change" is selected.
    Sample Image
  • In the Tomcat Plugin page, click on the Module view, make sure Auto Reload is Disabled. Default is enabled.
    Sample Image
    **NOTE: **
  • This is applicable in case of debug mode only
  • Only method code changes is supported, new added method,class, database script,tomcat is required to be restarted.

    Reference:

    Click here for mkyong.com link

Eclipse-Kepler, Maven and Setup Tomcat 7 debug (hot deploy)

Answer from following forum some what helps...
[Running Maven project on Tomcat from Eclipse

There can be a few reasons why you don't see the project in the Add/Remove projects dialog for Tomcat. Verify the following:

  1. You have m2e installed (http://eclipse.org/m2e/download/)
  2. You have m2e-wtp installed (http://www.eclipse.org/m2e-wtp/download/)
  3. Your Maven project imported as a Dynamic Web Application. Look for a Deployment Descriptor entry when you expand the project, it should be somewhere in the first few entries. It is the second one down for me on Eclipse Juno. Not there? It's probably not a web app. Go back and verify 1 & 2, then remove and re-import your project.
  4. Make sure that your web application is not too new for the version of Tomcat that you are using. Right-click the project and go to Properties > Project Facets. Look for Dynamic Web Module and check the version. If this version is too new for your Tomcat version, Eclipse won't let you add it. For instance, your Dynamic Web Module version is 3.0 and you're using Tomcat 6.

How to hot deploy newly created files to Apache Tomcat in Eclipse IDE?

You need to place the file in the place where your application is deployed on Tomcat (e.g.: Tomact7\webapps\myProject...), not in Eclipse Workspace location, this way your js can access the File either by its URL or relative path.

Remote deploy Tomcat webapp from Eclipse

If you can access the Tomcat manager application remotely then you can use the Tomcat Ant tasks or Tomcat Maven plugin to handle this. Both of these can then be called from within Eclipse.

Using either Ant or Maven also gives you the advantage of being able to deploy from outside of Eclipse. In my experience separating deployment from the IDE is helpful (our sysadmins don't run Eclipse!).

My personal choice is Maven, but Ant is equally capable in this area. I also use Maven profiles to let me easily switch between local/remote deployment (different server, passwords, etc).

Gradle Tomcat plugin - static resources hot deploy

It's generally recommended to use the Gretty rather than Gradle's built-in Jetty or Tomcat plugins. Gretty has support for hot-deployment of web resources as well as serving static resources strait from your workspace.

Tomcat and Eclipse Zero Turnaround Deployment

For these cases I set the eclipse build output to WEB-INF/classes as you have done and create a context file with the docBase set to the webapp folder (parent of WEB-INF) in the project. This is manually placed in conf/Catalina/localhost (assuming default configs for some elements of server.xml). End result is tomcat ends up serving from the development directory. So, change a servlet or other class and it is updated to the classes folder. Save a jsp and it is immediately available.

If project structured like:

src
|-main
|-webapp
|-images
|-js
|-WEB-INF
|-jsp
|-classes

Then context would be like:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/path" reloadable="true"
docBase="<pathtoproject>/src/main/webapp" />

Hot deployment issue with java class in MyEclipse

you don't mention the release of MyEclipse that you're using but, in all releases, you need to start Tomcat in debug mode for this to work. Also, note that some class changes cannot be hot swapped (e.g. if you change a method signature).



Related Topics



Leave a reply



Submit