Svetlin Zarev created TOMEE-2098:
------------------------------------

             Summary: TomcatWebAppBuilder does not correctly handle the case 
when startInternal(StandardContext) fails
                 Key: TOMEE-2098
                 URL: https://issues.apache.org/jira/browse/TOMEE-2098
             Project: TomEE
          Issue Type: Bug
    Affects Versions: 7.0.3, 7.0.4
            Reporter: Svetlin Zarev
         Attachments: cditest.war

If the application configuration fails in 
TomcatWebAppBuilder.startInternal(StandardContext) (see the attached 
application),  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:
{code}
 An invalid Lifecycle transition was attempted ([before_destroy]) for component 
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cditest]] in 
state [STARTING_PREP]
{code} 
and undeploy basically does nothing. And 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: 
https://github.com/apache/tomee/compare/master...SvetlinZarev:ctxFailsToStart 

What do you think ? 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to