Hi, If the application configuration fails in TomcatWebAppBuilder.startInternal(StandardContext), the web app builder tries to "undeploy" the app, but this operation can never succeed because the StandardContext is in state STARTING_PREP, while this operation requires it to be in one of NEW, INITIALIZED, FAILED, BEFORE_DESTROY_EVENT, STOPPED (see LifecycleBase:288). As a result tomcat logs an error: "An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cditest]] in state [STARTING_PREP]"
and undeploy() basically has no effect. If one tries to *redeploy* the app, the operation will fail because tomcat would not have cleaned up after itself. The correct way to handle this case would be to mark the StandardContext as unconfigured -> this will make StandardContext move into LifecycleState.FAILED after it process the lifecycle listeners and do proper clean up. Here is PoC of my proposal (just for demo, it has to be cleaned up): https://github.com/apache/tomee/compare/master...SvetlinZarev:ctxFailsToStart What do you think ? Best regards, Svetlin
