• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Replacing existing files with updated ones

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I have a simple webapplication deployed (using WAR) on tomcat and running on my machine.
Now I want to replace some existing java (.class) files with updated ones.

Can anybody please tell me how to do this as I don't want to deploy an updated WAR again.

Regards,
Arun
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sharma wrote:I don't want to deploy an updated WAR again.


Why? How is it possible to load updated classes if you want to update WAR?
 
Sharma Arun
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I don't want to replace/update the WAR file but want to update the running application by replacing some of the .class files in the standard extracted folder structure. Just like deploying a patch.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you asking how to do this without restarting the web app? That's quite tricky to pull off; you'd need to pay close attention to classloading details. If this was my problem, I'd look into using OSGi for this.
 
Sharma Arun
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply friends!

Actually It's done in simple steps:

1. Cut and paste the existing WAR file from webapps to some other location.
2. Stop the tomcat.
3. Replace the existing class files with the updated ones in application folder structure in webapps.
4. Restart the tomcat.
Now running application will reflect the updated functionality.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are going to stop and restart the server, why not just build and redeploy the whole war? That's the reason for war files in the first place. Picking and choosing files to update by hand sounds like a recipe for disaster to me.
 
Sharma Arun
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bibeault,

Your point is very genuine but what you will do if due to some reason you are not able to make a WAR and there is time constraint to update the running application.

Actually I was looking for a solution, for this scenario.

Thanks,
Arun
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless the war file is huge my guess would be that the Tomcat startup time likely dwarfs the time it takes to unpack the war file.

But if time is of the essence -for some reason that you haven't told us about-, then you should look into the solution I mentioned before; use OSGI to bundle the classes you may wish to update, and then stop that bundle and start the new one at runtime. No need to restart Tomcat, or even the web app itself!
 
Sharma Arun
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dittmer,

Thanks for your suggestion.
I just got a new thing to learn i.e. OSGi. Going to look into this.

Regards,
Arun
 
reply
    Bookmark Topic Watch Topic
  • New Topic