Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latest changes are not reflected in servlet (tomcat)

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?

like image 222
Dhiraj Valechha Avatar asked Jan 24 '12 03:01

Dhiraj Valechha


2 Answers

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

like image 87
Captain Fantastic Avatar answered Sep 21 '22 10:09

Captain Fantastic


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.

like image 39
Gene Avatar answered Sep 24 '22 10:09

Gene