14

I am developing an application with SpringMVC and Tomcat using Eclipse. The problem is: the server does not update the changes I am making.

One example:

@RequestMapping(value = "test", method = RequestMethod.GET)
    public ModelAndView test(){

        ModelAndView mv = new ModelAndView("test");                 
        System.out.println("test");
        return mv;
    }

Every time I hit the mapped url, Eclipse prints test in my console. If I comment out the println, I get the same result.

Attempts to fix the problem:

  • clean Tomcat directory
  • restart the server
  • close Eclipse
  • add/remove the project in the Server tab
  • delete the JSP the method is using
  • different browsers

All to no effect. It just looks like Tomcat is not updating any changes I make in the code.

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
Mauro M
  • 669
  • 1
  • 8
  • 25
  • Ideally, you are not running maven install which deletes the contents of the target folder. – We are Borg Jul 06 '15 at 14:55
  • 1
    So i should do a maven install everytime i change the code? – Mauro M Jul 06 '15 at 14:57
  • 2
    did you configure eclipse to build your project automatically ? (menu "project") did you configure your tomcat server instance to publish on change (double click on tomcat server to see "publish" section) ? is there any pending error on your project ("problems" view) ? – boly38 Jul 06 '15 at 14:58
  • 1
    Yes, yes publishing, no errors, the project was updating fine a few days ago – Mauro M Jul 06 '15 at 15:03
  • have u tried restarting the system. I have also faced the same issue in past, and gets resolved after restarting. I think this issue comes when we open so many files in eclipse paralley – Onki Jul 06 '15 at 15:23
  • Yes...u shud do maven install. – We are Borg Jul 06 '15 at 16:58

3 Answers3

12

To make Eclipse Tomcat update automatically or hot deploy you have to make certain changes in server configuration:

Below are the steps:

  1. Double clicks on the Tomcat Server, refer to "publishing" tab in the "Overview" view, make sure "Automatically publish when resources change" is selected. This should be the default option, to support “hot deploy” resources, for example : JSP, XML and properties files.

  2. In the Tomcat Plugin page, click on the "Modules" view, Select the Module then click on Edit button and make sure "Auto Reload" is "Disabled". Default is enabled.

  3. Start Project in DEBUG mode. Hot Deploy is supported in DEBUG mode only.

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
  • 2
    Yeah, all the setting are already like that, the project was working fine last week – Mauro M Jul 07 '15 at 13:35
  • As @MauroM says, it was working fine last week for me too. But launching the server in debug seems to fix it. It stopped working without touching it. Why? :C – Alfonso Nishikawa Nov 23 '16 at 10:34
  • For a more visual guide, see: http://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/ – ohaal Aug 03 '18 at 10:18
2

Two more things to check:

  • deploy directory: in the tomcat server UI and according to "deploy path" configuration, check that the output directory has read/write access (you could also remove it and try to publish again : check expected output resources/classes).
  • deployment assembly: in project properties menu; in the "deployment assembly" section, check that you are publishing all wanted resources. For example, in my case I download/generate some items from maven custom plugin phase and this resources are not published by default. I had to add some target subdirectories here...
boly38
  • 1,806
  • 24
  • 29
0

I had roughly the same problem and after tried it all with no success I gave up, created another fresh workspace and the problem was gone. Not the ideal solution but hey, it's an option.