Hi Svetlin, looks like a good idea but if we need to ensure it comes with tests for war and ear cases - they dont 100% have the same lifecycle.
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2017-07-13 14:50 GMT+02:00 Svetlin Zarev <[email protected]>: > 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 >
