0

I have a maven project ,say hello.In my /var/lib/tomcat8/webapps folder,i have placed its .war file,as hello.war.

Now I made some changes to a js file,run mvn package and copied the target/hello.war to tomcat8/webapps folder. The server still serves old JS file. Things I have tried: 1.Tried opening in private window. 2. Removing Catalina folder in tomcat8/work folder. 3. added to context.xml

But none of them work.Also deleted old hello.war in webapps and copied again,but still problem persists.

However,when i tried copying it as hello1.war in webapps folder,the servers serves the new file. Can someone guide me how to solve the problem?

6 Answers 6

3

Clean and rebuild your project war file.

Delete the hello folder from server. Then restart the server.

Sometime .js is loaded from cache, try Ctrl + F5

4
  • tried it,but after placing the .war with same name,still shows old content Mar 16, 2017 at 18:04
  • Clean and rebuild your project war file. Mar 16, 2017 at 18:06
  • Have you deleted old hello folder, please cross check it. Mar 16, 2017 at 18:07
  • yes i have deleted old hello.war and ran mvn package,then copied target/hello.war to webapps folder Mar 16, 2017 at 18:42
1

Tomcat isn't responsible for this. Some intermediate Web cache is doing it, or your browsser itself is caching.

2
  • I tried clearing my browser cache,and also tried opening in a private window,but nothing happens! Mar 16, 2017 at 18:41
  • @SrajanSoni So it must have been the other possibilty I mentioned in my answer. I didn't say anything about private windows. I don't know why you're telling me all this.
    – user207421
    Mar 22, 2018 at 23:05
0

Try to undeploy the app from http://localhost:8080 , in tomcat manager, then make shutdown from tomcat/bin and finally copy the war to your webapp folder and startup tomcat again

0

Unzip the war at some temp location and check if the unzipped JS file is the one which you are expecting. If it is, clean the tomcat webapps directory by removing the previous version war and the unizpped directories and files from that war. After that, copy the new war into your webapps folder and start the server.

One other thing, if you are using eclipse and using external maven build then after re-building your project refresh that project in your workspace and then copy the war file.

2
  • I unzipped it and found new files.Cleaned all files from webapps folder and copied new hello.war there.Still the same problem.However,upon copying it as a different name(which tomcat sees for first time) results into correct files!! Mar 16, 2017 at 18:44
  • @SrajanSoni re-install tomcat maybe?
    – opensam
    Mar 16, 2017 at 20:57
0

The ideal thing to do and which I normally follow is :

  1. Delete temp folder
  2. Delete work folder
  3. Delete webapps/hello.war file.
  4. Delete webapps/hello folder
1
  • Just to add, stop the server and do above steps, and then copy the war file and start again.
    – Sagar Jani
    Mar 23, 2017 at 1:31
0

In my case one file was stale and served old content whatever changes I did, the other one used on the same jsp page was successfully refreshed.
Restart/Publish/Clean Tomcat work directory... in eclipse didn't help.
The only thing which did the trick was cleaning the cache in Firefox.
I still have no clue why first file was saved in cache, and the other - not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.