2

I am having problems when editing template-files(HTML-files) in my Maven-project. I have made the Maven-project an Eclipse-project with the command "mvn eclipse:eclipse" (if it matters). I am using the Apache Velocity Engine as template engine for this project.

The problem arises when I'm editing the files in Sublime, and then save the file and refresh the browser. The changes does not show! If I however open the template file in Eclipse, just open it, I can even just open and close it right away, and THEN refresh the browser, the changes will show.

I have done a test to see if this problem occurs on other simple projects as well, and with a single HTML-file and a simple http-server, the work I save in Sublime shows as normal.

Does anybody know what is happening here? Am I bound to keep on using Eclipse as a HTML-editor? :( Does the Eclipse project files prevent me from using other editors? Why are the changes only showing when I open the files in Eclipse?

Any help is greatly appreciated!

user2602152
  • 687
  • 7
  • 24

2 Answers2

1

In order for the changes to take place you have to right-click the file in Eclipse explorer tab and choose "refresh" in order for the (static) changes to be reloaded to Apache. For dynamic changes you'll need to restart apache or use a plugin such as JRebel.

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
  • Thanks for the reply! Yes, this seems to be the case. It works if I choose "refresh", as you suggest, or if I just open the file. I guess Eclipse reloads the file to my Embedded Jetty container when this happens? Is it not possible to reload static changes without using Eclipse? – user2602152 Sep 10 '13 at 17:24
  • Not with eclipse AFAIK... You can run Jetty/Apache independently and work with sublime on the deployed version. – Nir Alfasi Sep 10 '13 at 17:27
  • I'm running the Maven-project from the command line, and then working on the files with Sublime, but this does not work without opening or refreshing in Eclipse. – user2602152 Sep 10 '13 at 17:55
  • That's cause you're running Jetty through Eclipse. Please refer to my previous comment. – Nir Alfasi Sep 10 '13 at 18:08
  • I'm sorry for not understanding, but I can run the server with Eclipse shut completely down. I would think that that would mean I am running it independently from Eclipse, or are there something that depends on Eclipse still? – user2602152 Sep 11 '13 at 07:09
  • If you're running it when Eclipse is shut down then it's independently. I don't have experience with Jetty but it should be very similar to tomcat and if you change a static file Jetty should serve the updated content unless there's some caching mechanism turned on (one which Eclipse takes care of when you run Jetty through Eclipse - and you're doing "eclipse refresh") – Nir Alfasi Sep 11 '13 at 16:36
  • It seems to be the same problem as here: http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages and here: http://stackoverflow.com/questions/696738/how-to-prevent-caching-of-static-files-in-embedded-jetty-instance and here: http://wiki.eclipse.org/Jetty/Howto/Deal_with_Locked_Windows_Files But I am on a Mac, and none of the solutions above fixes the problem. – user2602152 Sep 12 '13 at 15:24
  • A shot in the dark: you can try and set the sesions's MaxAge to a really low value and hope that it'll try to re-load the resource. Please let me know if it worked for you: http://docs.codehaus.org/display/JETTY/webdefault.xml – Nir Alfasi Sep 12 '13 at 15:33
  • Sorry for the delayed response. The solution was simply to copy the files to the "target"-folder of the webapp on save. Eclipse does this automatically. This wasn't knowledge I had, unfortunately. :/ – user2602152 Nov 11 '13 at 17:53
1

Eclipse copies the files to the "target"-folder in the webapp. Sublime(and others) does not do this automatically, so you need to do this manually, or by a plug-in that will copy the files on save.

user2602152
  • 687
  • 7
  • 24