Link to home
Start Free TrialLog in
Avatar of Gangadhara Melukote
Gangadhara MelukoteFlag for United States of America

asked on

Dynamic loading of java class

I want to reload the java class at runtime (without restarting server). I am building a mechanism like this.

1) Create a scheduler class which runs every hour.
2) The scheduler class will hunt for any java class file modified within last one hour (I am replacing the old class file with new class file) and loads to the app server container using 'ClassLoader'.

Can someone anyone please let me know, whether is this safe to use in production environments?. I read some details about ClassLoader like 'frequently using these mechanism may result in server crash'. If this is true, what is the best way to use dynamic loading of class file without server/application restart?

Application Server: WebSphere Community Edition (WAS CE)
OS: Linux

Thanks in advance.
SOLUTION
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
agree with sharonseth.

In PROD environment, there wont be any situation like this (class file is modified). Any specific reason/case ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gangadhara Melukote

ASKER

Thanks for your valuable responses. To do hot deployment/redeployment, I need to login for the app server console. I am trying to avoid for this step for each time when I wanted to deploy updated code on server.

1) My machine OS is XP and our DEV server is in Unix box.
2) Once I do any code change, compile my code and using FTP transferring the compiled class file to the APP server location.
3) Need to login to the app server console and restarting the module/application to see the code change effect.

Here I wanted to get rid  3rd step (bit lazy to do this step again and again :D ) and planning to develop a utility class. This utility class will frequently (5/10 seconds) monitoring the any file changes in APP server location, if it found any file modified recently, the it should load to the container.

I agree with all of you that the above utility class should not be run in production environment. I am just curious about this kind of process having any side effects.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial