Roberto Leong wrote:
hi can someone please save me a couple days of hacking embedded catalina and teach me what to do when deploying a new war file on runtime? my guess is that i have to create a new context but i don´t see any methods on EmbeddedManager to add a new context to an existing engine/host (there are no methods to retrieve these, only to remove/create) thanksRoberto Leong


Isn't creating a new context what you want to do?  If you are using the EmbeddedManager class (because you're in a JMX managed environment), you presumably have a "host" object already -- to deploy a new WAR you would unpack the WAR to a directory structure and execute:

    EmbeddedManager manager = ...; // Your EmbeddedManager object
    Host host = ...; // Host object you want to add this context to
    String contextPath = ...; // Desired context path
    String docBase = ...;    // Pathname to unpacked directory
    Context context = embeddedManager.createContext(contextPath, docBase);
    ... customize context properties as needed ...
    host.addChild(context);

If you want to replace an existing webapp, you have to remove the old context first, then add a new one on the same context path following the instructions above.

If you are using the Embedded class directly, the procedure is virtually identical -- just call createContext() and the other creation/removal calls on the Embedded class instance instead.  The "main()" method in org.apache.catalina.startup.Embedded offers an example of the kinds of things you can do here.

Craig McClanahan

NOTE:  In the future it will be possible to run a webapp directly out of a WAR, but that is not currently supported.
 

Reply via email to