Bug 51555 - An invalid Lifecycle transition ([before_stop]) for component in state [INITIALIZED]: MapperListener
Summary: An invalid Lifecycle transition ([before_stop]) for component in state [INITI...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.19
Hardware: PC Windows XP
: P2 minor (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 21:40 UTC by Konstantin Kolinko
Modified: 2011-07-26 08:25 UTC (History)
0 users



Attachments
TEST-org.apache.tomcat.util.net.TestXxxEndpoint.BIO.txt (18.69 KB, text/plain)
2011-07-25 21:40 UTC, Konstantin Kolinko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2011-07-25 21:40:38 UTC
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().
Comment 1 Konstantin Kolinko 2011-07-25 23:54:44 UTC
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)
Comment 2 Mark Thomas 2011-07-26 08:25:57 UTC
Fixed in 7.0.x and will be included in 7.0.20 onwards.