9

I am working on my project of quiet sometime now I am using tomcat and eclipse both working correctly till now..

I deployed the war on 22-1-2012 ( with some print messages) it was working correctly then next day I made some changes removed some messages and redeployed the file...In my webapps folder it is showing the latest time for 'last modified' of my war file.. what wrong i am doing tell me..

P.S any changes to JSP pages of same project are reflected but servlet class is unchanged

This is what log file shows _SEVERE: A web application appears to have started a TimerThread named [MySQL Statement Cancellation Timer] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled. _

Well this is the summary of my problem i hope i can explain you now the problem i again performed the following steps

  1. Deleted my webapp directory from webapps
  2. Tried to access servlet (it shows 'Resource not available')
  3. Make some changes in print statement to debug
  4. Redeployed WAR from eclipse
  5. Again when access that servlet it is not the latest version it is showing same old messages.

Now tell me if there is solution.... Thanks in advance


After trying so many thing i just observed when i deploy the WAR file non-JSP servlet class files were not included in WAR when I manually add these class files in WAR all the changes are updated.. So now can u tell me how to auto deploy these in WAR..whats the problem?

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Dhiraj Valechha
  • 161
  • 1
  • 2
  • 9

11 Answers11

7

The JSP files are not updating because they were precompiled, and even though they may pull information from files that have changed, each JSP file that may be affected needs to have a minor change made to it, like add a space and then remove a space, and then save it.

Then build your WAR, and then the updates should show. I went through this same problem tonight and none of the other answers helped. The key is, to check the file dates in the Tomcat directory of where you deployed the WAR. I noticed that even though I was deploying an entirely new cleaned WAR, and deleting all folders, there were still older cached files in there, probably because Eclipse keeps them to save compile time, thinking they don't have any changes.

Hope this helps

5

Go to Servers View in Eclipse:

Double click on your server. In my case, it’s Tomcat.

A Tomcat Web Module should pop up. Click on Modules tab at the very bottom (see Pic1)

Select your project. Click “Remove” button.

Pic 1: enter image description here

Now you should see a star next to the Tomcat Tab. That means you need to save your changes. So do a Control+S.

Pic 2: enter image description here

Right-click on your project in Project Explorer. Go to Maven -> Update Project…

Pic 3: enter image description here

Now this is the important part, make sure you have “Force Update of Snapshots/Releases” checked. Having that part checked is critical. Then click Ok.

Pic 4: enter image description here

Now look at your Server View. It should look like this, with a “Restart” warning telling you that it’s out of sync.

Pic 5: enter image description here

Right-click on it and choose Restart

Pic 6:

enter image description here

Let the server restart. Now if you go back to the Server View, you should see that it’s synchronized. That’s what you want. Like this:

Pic 7: enter image description here

Now you should be able to right-click on your project and choose “Run As” -> Run on Server and you should see your changes.

Pic 8: enter image description here

If things still didn’t update, go back and look at your Server View and make sure it doesn’t say the restart thing like in Pic 5 above. If it does, please restart your server again like in Pic 6. Then click refresh on the browser.

Gene
  • 10,819
  • 1
  • 66
  • 58
2

Go to browser settings and clear the cache.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
0

go to catalina home\conf\context.xml

change <Context> to <Context reloadable="true"> Make sure you restart tomcat. Boom. You might have to still press F5 or Ctrl+F5 two or three times though.

Vili
  • 1,599
  • 15
  • 40
boom
  • 1
0

is your tomcat server.xml pointing to the right Workspace? to make sure, you go to tomcat installed directory -- find server.xml in the confi folder

0

for every war file, tomcat creates a similar named folder. Delete the folder, try to redeploy war again, hope it will reflect.

Nitin1706
  • 621
  • 1
  • 11
  • 21
0

In web.xml file add one letter at the end and delete it and then by pressing enter save the file. After that run the program and it works with updated data.

0

TL;DR: Make sure your eclipse project is set to build automatically: Project > Build Automatically

I apologize for answering without having complete knowledge of what the WAR files are, but I assume the WAR files are the compiled .class files in the "build" folder.

I noticed that when I saved my Servlet "HelloWorld.java" in my case, that the compiled "HelloWorld.class" did not update at all. I could force the project to build by right clicking the java project and selecting "Build Project". After Building the project, the "HelloWorld.class" file was successfully updated, but the updated code still did not show on the server.

To get the results to show on the server, I had to click on my server (mine was called "Tomcat v9.0 Server at localhost [Started, Synchronized]") and then I clicked "Publish to Server". If you do not see your Servers, do: Window > Show View > Servers

I didn't even have to restart the server, after a few seconds (and refreshing google chrome), the website updated itself!

Of course manually building and publishing (and possibly restarting) the server is kind of too much for my lazy fingers, so I found how to fix it. You can just go to Project > Build Automatically. and then the website will update anytime you save a modified java file.

This solution worked for me because I was only missing the automatic building. but you could also have a problem where the server doesn't automatically publish.

I personally didn't have this problem so I'm just speculating, but there are some settings for publishing. In your "Servers" view, double click on your server name (in my case, double click on "Tomcat v9.0 Server at localhost [Started, Synchronized]"). A tab should open up showing your server settings. Expand the section titled "Publishing", and set your publishing settings as you desire. Right now mine is set to "Automatically publish when resources change".

Unfortunately I have no clue how to make the server automatically restart upon the saving of a modified .java file.

Funny Geeks
  • 483
  • 5
  • 12
0

any changes to JSP pages of same project are reflected but servlet class is unchanged

It is not clear what you are saying.

  • If you are saying that the updated JSPs are in the expanded webapp directory, but the generated / compiled JSP classes have not changed (in the work directory), then try deleting the classes from the work directory. You may need to restart the web container too.

  • If you are saying that the non-JSP servlet classes have been updated (in the webapp) but you are not running them, then try restarting the web container.

  • If you are saying that the non-JSP servlet classes have not been updated in the webapp directory, then something went wrong in the webapp deployment. Shutdown the web container, delete the webapp directory (and the compiled JSPs for good measure) and restart the webapp.


After trying so many thing i just observed when i deploy the WAR file non-JSP servlet class files were not included in WAR when I manually add these class files in WAR all the changes are updated.. So now can u tell me how to auto deploy these in WAR..whats the problem?

So the problem is nothing to do with deployment. The problem is that you are not building the WAR file correctly in the first place.

I can't help with this because I don't use Eclipse to build my WAR files. (I use Maven so that the build process is scripted and reproducible ... and doesn't depend on me clicking the right buttons in the right order every time.)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • ..3rd one is right non-JSP servlet classes have not been updated..i have tried all these 1.Restarted the web container 2.Deleted the war file and respective folder from webapps and redloyed 3.Restart almost everything from eclipse to PC many times everytime i am getting the previous output i.e updated 2 days back latest changes are not reflected on non-JSP class files – Dhiraj Valechha Jan 24 '12 at 03:37
  • After trying so many thing i just observed when i deploy the WAR file non-JSP servlet class files were not included in WAR when I manually add these class files in WAR all the changes are updated.. So now can u tell me how to auto deploy these in WAR..whats the problem? – Dhiraj Valechha Jan 24 '12 at 05:13
0

Check the log files for Tomcat, I bet there is a startup problem with your web app and it's not getting deployed.

Perception
  • 79,279
  • 19
  • 185
  • 195
  • Jan 22, 2011 5:27:38 AM org.apache.catalina.loader.WebappClassLoader clearRefere ncesStopTimerThread SEVERE: A web application appears to have started a TimerThread named [MySQL Sta tement Cancellation Timer] via the java.util.Timer API but has failed to stop it . To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled. Jan 22, 2011 5:27:38 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive MobileServlet.war' – Dhiraj Valechha Jan 24 '12 at 03:51
  • well above errors are there while a deploy the war.. Do you think re-installing tomcat will help? – Dhiraj Valechha Jan 24 '12 at 03:55
  • Please add the error message to your original question (you can edit it). I doubt that the error you showed is the one preventing your web app from loading. Is there any other error message there? – Perception Jan 24 '12 at 04:01
  • thanks for the help i have added log file error to my question – Dhiraj Valechha Jan 24 '12 at 04:07
0

The reality is that Tomcat cannot be running code it doesn't have a copy of. Especially if you have restarted it. It sounds like there is a separate "copy" of your web app that is actually in use. Either made inadvertently by you (hey lets face it, we've all done this) OR made by Tomcat in a location you weren't aware of.

Pick a unique file that exists within your web app. Maybe an icon name, or a configuration file name. Search the entire hard drive for it to locate exploded copies of the WAR file. This will help find it in a temp directory or working folder. Make sure to clean those up.

Also, make sure you are running the Tomcat that you think you are. Most developers with multiple Tomcat installations has also made the mistake of deploying to a different location. Look at the process list to see the arguments given to the JVM at launch time. Be sure to also check environment variable for things like CATALINA_HOME.

EDIT: Your update that JSP pages change, but classes do not make me think you have multiple JAR files on the class path that have the same file in it (one older version loaded first) OR you have changed a class name in the code base, but not updated references to it.

rfeak
  • 8,124
  • 29
  • 28
  • @rfreak well deploying following error is there in my log file _SEVERE: A web application appears to have started a TimerThread named [MySQL Statement Cancellation Timer] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled_ Your answer looks valid but everytime i am deploying so it means its using proper tomcat... – Dhiraj Valechha Jan 24 '12 at 03:58
  • @rfreak Your can you tell me solution to your edit section of multiple JAR.. As much I know there is only 1 JAR file – Dhiraj Valechha Jan 24 '12 at 04:05