Search code examples
javamethodscallwardeploying

How to call a Java method while deploying a WAR


How to call a Java method while deploying a WAR


Solution

  • It's not clear what you mean by "deploy". Is that the moment when the WAR file arrives on the app server? Maybe you gin something up with Ant. Is that when the app starts up? Maybe you can do it with a ServletContextListener.

    There's no mechanism for doing so built into any Java EE app server I know of, so you're out of luck if Ant isn't suitable. You need something that does the deploying to do it for you.

    What's your purpose for doing so? What does this method do?