Consider a default webapp configuration in Maven (for the test case I used struts2-blank-archetype from https://repository.apache.org/content/groups/public/archetype-catalog.xml ).
This archetype comes with maven jetty plugin’s version 6. With the configuration below, if I change a jsp under /src/main/webapp/WEB-INF/ and save it, refreshing the browser will show these changes.
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.21</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> </configuration> </plugin>(notice that one doesn’t even need to put the scantarget element, as we don’t want a complete container reload when you just change a jsp).
However, the exact same configuration of version 8 of the plugin (see below) does not work. If I change the same jsp, refreshing the browser will show the old JSP contents. Only by stopping and starting the server will I see the changes.
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.7.v20120910</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> </configuration> </plugin>
What is wrong with this configuration, and what configuration would produce the same results in version 8 (ie, auto-refreshing the jsp contents without restarting the server)?
EDIT:
Here’s a 2 minute test you can try:
- Create archetype struts2-archetype-convention (“mvn archetype:generate”, 308, package war).
- Edit the pom and set the jetty plugin configuration to the one listed above (version 6)
- mvn jetty:run
- Open the browser on “http://localhost:8080”
- See “Languages” on the page
- Edit /src/main/webapp/WEB-INF/content/hello.jsp – change “Languages” for something else. Save.
- Refresh the browser and see the change.
- Repeat the steps. On step 2, change the artifactId and version to the ones listed above (version 8)
- Confirm the webpage does not change upon refresh after you perform the change in the JSP.
After the previous comments I was able to identify the root cause of this issue. While this is a bit specific to our use case, I share this with the community nonetheless.
This is basically caused by the timestamps of the files. My work directory is an NFS mount of another server. For some strange reason* the clock on that server is delayed. This means that if it’s 9:00 and I change the JSP file, the file will be timestamped with 8:40.
There might have been a change in Jetty from 6 to 8 regarding the strategy used for JSP file reloading – while Jetty 6 does not seem to care about the file’s timestamp and refreshes anyway, Jetty 8 is more sensitive and does not reload the file.
So the “solution” here was simply to update the remote NFS server’s clock.
*meaning the NTP deamon is running, I can ping the ntp servers, other machines on the same networks have the same NTP settings and yet this machine is still having its clock drift