You are creating the context as a subcontext of initCtx
:
srvCtx = initCtx.createSubcontext("myapp");
When you are destroing it however it seems like you are trying to destroy it as a subcontext of srvCtx
.
srvCtx.destroySubcontext("myapp");
The myapp context is not a subcontext of srvCtx
, it is a subcontext of initCtx
. It should work better with
initCtx.destroySubcontext("myapp");