I have an application deployed in weblogic. I have thread that starts on weblogic start. I am using Spring configuration, so on load of the class, thread also gets started, since the thread start method is in constructor of the class. But when I try to force stop the application in weblogic, the thread keeps on running. The thread wakes up every 1 minute and do the processing.
I know I have to stop the thread by interrupting the blocked state and to protect the loop from further iteration by setting a volatile flag.
One option would be to just make sure your Runnable handles interruption appropriately and an ExecutorService to submit it for execution.
That way you could use ExecutorService#shutdown() / ExecutorService#shutdownNow() to stop its execution, which I guess you could call from a shutdown hook, using Runtime#addShutdownHook().
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I have the same problem in Weblogic 8 and Weblogic 10.
What I found is that if you have a servlet in you deployed .ear file that does :
the servlet will continue writing to sysout after you stop the ear.
the servlet will continue writing to sysout after you undeploy the ear.
the servlet will finally stop writing when you shutdown the application server.
The proposed shutdown-hook solution is not useful here because the hook will only be called upon server shutdown.
Anyone know of a hook that can be called at the moment of the application-stop (or at the very least at the moment of the application-undeploy) ?
Seems to me a pretty huge breach in weblogic, the fact that your application will effectively keep running after you stop it and even after you undeploy it !
Comments & suggestions are welcome ...
posted 9 years ago
another thing ...
if your servlet does this :
Then upon application-undeploy, the servlet will keep writing until we reach time t, but then once we reach time t, the servlet will stop writing, leave the while loop, and ... do nothing ! That is, it does not call executeAction().
So what exactly is application-undeploy ?
It leaves your application running, sort of ?
It allows certain actions (looping, writing to files), but not others ?
I'll be very grateful to anyone who can explain this to me, I've gone through all of Oracle-BEA-Weblogic docs and can't find a straight answer.
posted 9 years ago
i tried the same test and it seems that executeAction() can execute after application-undeploy (maybe it depends on what that method does).
my application is able to query an oracle database via JDBC and print the results in a file AFTER having been "undeployed" in Weblogic !
seems to me that it's unsafe to undeploy an application in Weblogic unless you follow that by stopping/restarting the application server.
anyone care to share their experience with this or any explanations ?
anyone have a suggestion on how to make my application stop upon undeploy ?
posted 9 years ago
found a partial solution / work-around.
recall that i was looking for a hook that's launched at application-stop (similar to the Runtime shutdown hook that is called upon server-stop).
in other words, a method that's automatically called upon application-stop.
it turns out that application-stop launches the Garbage Collector, or at least it does in the tests that i've done.
i think the GC will call the destroy() method on all your loaded servlets.
so it suffices to add a destroy() method to a servlet, and there you have your application-stop hook.
so i wrote a simple servlet that launches upon application-startup (web.xml : <load-on-startup>1</load-on-startup>) and its destroy() method redefines a static boolean in a Singleton class that i've added as a condition to my while loop above.
when i do an application-stop in weblogic, the GC is launched, the destroy() is called, the boolean is redefined, the while loop stops, and we're golden.
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad