Friday, February 4, 2011

Can you programmatically restart a j2ee application?

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.

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

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

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

    From pkaeding
  • 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.

    From shsteimer
  • @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.

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

    From shsteimer
  • 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.

    From jsight

0 comments:

Post a Comment