2

I was given a template of a Struts project to work on, and I noticed that when I run the web project on integrated Tomcat in Eclipse and make changes to the .jsp viewpages, they don't automatically reload after a few seconds - which does happen in other projects I made myself.

So I figured this was a configuration issue and I did some research, I had a look at my Tomcat server settings:

(x) Automatically publish when resources change (1 second interval)

But because my own projects reload and I use the same server for them, I figured it must be an application specific issue. So I looked at context.xml to see if there was anything to change here

<Context 
...
reloadable="true"
...
>

Which I can only assume tells the server to indeed reload the application on changes.

So I really can't figure it out. It seems to me like everything is in order here. What am I missing?

informatik01
  • 16,038
  • 10
  • 74
  • 104
arnehehe
  • 1,386
  • 1
  • 17
  • 33

2 Answers2

1

From Apache Tomcat documentation about the Context attributes:

reloadable

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

Also maybe this will be interesting for you: Using Tomcat Reload Features To Speed Up Development

informatik01
  • 16,038
  • 10
  • 74
  • 104
  • Please note that I have already set the Context attribute reloadable to "true" as mentioned in original question, and that this doesn't actually work for some reason. – arnehehe Jan 10 '13 at 14:48
  • @arnehehe Where did you set it? If you deploy your app thru Eclipse, there must be some **Servers** project and inside that there is a _Context.xml_. There should be _reloadable="true"_ set. – informatik01 Jan 10 '13 at 15:14
  • Plus do you have _Project => Build Automatically_ checked? Do you save changes after making them (sorry, just checking). I never had any problems with my Java web projects related to relodability, so to say. It's strange ... And it's not an application issue. It is a **container** job to automatically reload deployed apps. – informatik01 Jan 10 '13 at 15:17
  • I had a look, _reloaded=true_ is enabled in my context.xml file, _Project -> Build Automatically_ is checked, and I'm sure I'm saving it. I had a closer look at my _Servers_ view during the changes I make, when I change something in one of my own made applications while it's deployed on the server, the Server goes from Synchronized->Republish->Publishing->Synchronized – arnehehe Jan 11 '13 at 08:18
  • When I change something in the Struts project I received (that I don't really know that much of its intimate configuration about) and look at the Server (while deployed), the Server status goes from Synchronized->Republish->Publishing->Restart and stays at Restart, which I assume means I have to restart the server to change anything. Does this help? – arnehehe Jan 11 '13 at 08:21
  • 1
    It actually just hit me - In my project that synchronizes itself back up every time, all my .jsp's are in the WebContent folder. In the project I was given, they are seperated in packages in the /src/ folder. Could this be the reason why the .jsp's aren't reloaded? Because they're in /src/? – arnehehe Jan 11 '13 at 08:22
  • @arnehehe I usually keep all my JSP under WebContent too. But, if I'm not mistaken, if the project uses Maven, then maybe JSP source files are too stored under _src_ like here: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html. It is strange that the changes are not reloaded **if** all the requirements are met. Try to experiment in this case. I am sorry I couldn't help – informatik01 Jan 11 '13 at 14:30
  • @arnehehe btw are you sure you added your Struts project to the Tomcat server configured in Eclipse (just checking)? In the Servers tab in Eclipse, right click on the Tomcat server, choose "Add and Remove". Is it added? – informatik01 Jan 11 '13 at 14:45
  • @arnehehe OK, here one more thing. On the _Servers_ in Eclipse, right click your Tomcat server, choose _Open_ (or just select Tomcat and click F3), in the opened window below choose **Modules** tab, make sure your Struts project is added, select it and click _Edit_ button on the right and make sure *Auto reloading enabled is checked**. May be this will help. If not I'm sorry again, it's hard to say something not seeing the project and all settings. – informatik01 Jan 11 '13 at 14:52
  • 1
    I won't be able to test it until monday. Thanks in advance for all the help – arnehehe Jan 11 '13 at 16:10
  • @arnehehe No problem. Good luck to you. – informatik01 Jan 11 '13 at 17:14
  • I've had a look at your suggestions to see how they complied with my project settings. The project is indeed added to the server, when checking the **Modules** tab, then my Struts project, then _Edit_, I can confirm that _Auto reloading enabled_ is indeed checked. I understand that it would be far more convenient to put the .jsp files in WebContent, unfortunately I have to put them in a package structure in /src. I'll meet the person that made the initial Struts template next week and ask him if he knows the answer. – arnehehe Jan 14 '13 at 10:49
  • @arnehehe I see. Good luck to you! – informatik01 Jan 14 '13 at 17:41
0

I ran into the same problem, with a Java/Spring project that I imported via its Maven .pom files into Eclipse.

I found that I had to run the project with "Debug" instead of "Run" - only then, changes to my .jsp files were noticed, so that a reload of the web page would show the changes almost instantly.

Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149