Created attachment 27313 [details] TEST-org.apache.tomcat.util.net.TestXxxEndpoint.BIO.txt While running TestXxxEndpoint test I observed the following error - see attached log: An invalid Lifecycle transition was attempted ([before_stop]) for component [org.apache.catalina.connector.MapperListener@e3849c] in state [INITIALIZED] org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_stop]) for component [org.apache.catalina.connector.MapperListener@e3849c] in state [INITIALIZED] at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:386) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:212) at org.apache.catalina.connector.Connector.stopInternal(Connector.java:973) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225) at org.apache.tomcat.util.net.TestXxxEndpoint.testStartStopBindOnStart(TestXxxEndpoint.java:172) The test case contains two tests. The first one (on port 8001) succeeded, while the second one (on port 8002) failed with "Address already in use: JVM_Bind". This failure to bind to 8002 was unexpected and does not occur during normal run. While Tomcat was stopping after failed start, the above "invalid Lifecycle transition" exception was thrown by MapperListener. I was testing with BIO connector only, running a single test (test.entry=org.apache.tomcat.util.net.TestXxxEndpoint). I think that the cause of the startup failure was that I accidentally started two copies of Ant in parallel. In Eclipse it happens if you double-click on "Run External Tool" button. Looking at o.a.catalina.connector.Connector#startInternal(), it does - protocolHandler.start(); - mapperListener.start(); The logs show that protocolHandler.start() call failed. Thus mapperListener.start() was not called. This second test TestXxxEndpoint.testStartStopBindOnStart() runs with "bindOnInit" property of connector set to "false". Thus binding failure did not happen in init(), but occurred in start().
A simple way to reproduce this: 1. Add bindOnInit="false" to HTTP connector in server.xml and remove AJP connector. 2. Start an instance of Tomcat. 3. Try to start second instance of Tomcat. It fails with the same "invalid transition" exception: 26.07.2011 3:50:09 org.apache.catalina.core.StandardService destroyInternal SEVERE: standardService.connector.destroyfailed org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [org.apache.catalina.connector.MapperListener@17779e3] in state [INITIALIZED] at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:386) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:278) at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:979) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:284) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:578) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:284) at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:789) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:284) at org.apache.catalina.startup.Catalina.stop(Catalina.java:695) at org.apache.catalina.startup.Catalina.start(Catalina.java:655)
Fixed in 7.0.x and will be included in 7.0.20 onwards.