• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

load new class not old one

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

I modified one class of my application, but I don't want to rebuild the whole now and redeploy the whole application.
I just want to create a new jar which only contains this modified class and only deploy this jar.
So when the application restarts, it will load the new class instead of old one.

How can I do this?

Thanks
 
Sheriff
Posts: 67595
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
"dennis dl", please check your private messages for an important administrative matter.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few ways of doing this, but all are more complicated than redeploying the full app. Why don't you want to rebuild and redeploy the whole app?
 
dennis liang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

If I put the jar in a classpath and let class loader loads it first, the old class will not be loaded.
Someone tried this way before? How?

Thanks

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Completely unreliable: you should never rely on the new class being picked up first--you do not control the classloader, the classloader might change, etc. Having multiple versions of the same class on the classpath is a recipe for tears.
 
dennis liang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:There are a few ways of doing this, but all are more complicated than redeploying the full app. Why don't you want to rebuild and redeploy the whole app?



Please let me know these ways of doing this.
Thanks
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before I go to any length answering that, please tell us this:

Why don't you want to rebuild and redeploy the whole app?

 
dennis liang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.
Here is the scenario.
The application is in production. need to modify one class to fix a simple bug.
Dropping a simple jar in the application without touching the whole application is a simple solution for now.
Next release can rebuild the whole application and conduct full test in QA and redeploy it.

Thanks
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it's *not* a simple solution, that's the thing.
 
dennis liang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know there was an app. They put a patch jar in a folder of the app.The loader loaded the new class instead of old one when restart the app. Very useful way.
But I did not ask how.

Thanks
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the use of the class is very localized (and described via an interface), then you can encapsulate its usage via a classloader of your own. If you want to redeploy the class your code can throw away the classloader, and then create a new one that loads the class from the new jar file. It's not trivial, but not particularly hard either if you understand classloaders.

Or you can make it much easier on yourself and use OSGi; this is one of its primary use cases.
 
reply
    Bookmark Topic Watch Topic
  • New Topic