tags:

views:

327

answers:

7

Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how?

I would like to be able to do it in an app-server-agnostic way, if it is possible.

The application will be run on many different app servers-- basically whatever the client prefers.

If it isn't possible to do this in an app-server-agnostic manner, then it probably isn't really worth doing for my purposes. I can always just display a message informing the user that they will need to restart the app manually.

+2  A: 

Most application servers provide a JMX interface, so you could invoke that.

Hank Gay
A: 

could you please specify what application server you are using? That would make the question easier to answer.

shsteimer
A: 

@shs- I was kind of deliberately being vague on the app server; I just edited the question to reflect this.

pkaeding
+3  A: 

I would suggest that your unlikely to find an appserver agnostic way. And while I don't pretend to know your reqs, I might question a design that requires the application to restart itself, other than an installer that is deploying a new version. Finally, I would suggest that for any nontrivial purpose "any" appserver will not work. You should have a list of supported app servers and versions, documented in your release notes, so you can test on all of those and dont have to worry about supporting clients on a non-conforming server/version. From experience, there are always subtle differences between, for example, Apache Tomcat and BEA WebLogic, and these differences are often undocument and hard to determine until you run into them.

shsteimer
A: 

@shs- Thanks for your insight. The reason I want to be able to restart the application is indeed for updates; when the user installs a new module, the app will need to be restarted.

Also, yes, we do have a list of supported/tested appservers; so it wouldn't need to work everywhere, but I just didn't want to have to write the code multiple times to deal with the different ways of doing this.

pkaeding
A: 

@pkaeding - Thanks for clarifying. Good luck, if you do find a solution I'd love to see it.

shsteimer
+1  A: 

I'd suggest using servicewrapper to manage the application server, and then use its api methods for requesting a restart of the service. There would be some configuration involved and its hard to know if this would work in your particuar environment, but thats the only solution that I know of which is even reasonably cross-server compatible.

jsight