1. Mule
  2. MULE-4589

java.lang.IllegalStateException: Phase 'start' has already been executed


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2 (EE only)
    • Fix Version/s: 3.0.0
    • Labels:
    • User impact:
    • Migration Impact:
      This fix did not make it to Mule 3.0
    • Similar Issues:
      MULE-4590java.lang.IllegalStateException: Phase 'dispose' has already been executed
      MULE-5233CLONE - java.lang.IllegalStateException: Phase 'start' has already been executed
      MULE-6692java.lang.IllegalStateException: Already in lifecycle phase 'start', cannot fire the same phase twice
      MULE-4268Retry should not stop/start connector
      MULE-4893Mule container shouldn't attempt to stop an already stopped app
      MULE-3217Restlet Project from tutorial page will not start due to _muleSimpleRegistryBootstrap not being able to load due to registry collision on Object "transformer: _ObjectToRequest" has already been registered in the Registry.
      MULE-6606Phase execution engine is not dispatching to next phase if previous phase is not supported
      MULE-7552Transaction isRollbackOnly() should considered already finished transactions
      MULE-5152Do not require MULE_HOME to be set for starting Mule
      MULE-2113Lifecycle phases should be in pairs


      I am using Mule ESB EE 2.2.2 and testing it using Junit tests with the FunctionalTestCase mechanism (that is my Junit tests all subclass from this). I get this except intermittently when running the tests.

      java.lang.IllegalStateException: Phase 'start' has already been executed
      at org.mule.lifecycle.GenericLifecycleManager.checkPhase(
      at org.mule.DefaultMuleContext.start(
      at org.mule.tck.AbstractMuleTestCase.setUp(
      at org.mule.tck.AbstractMuleTestCase.runBare(

      The fix to the problem is below. It turns out that when I run the test cases it starts my configuration which includes several examples. The way the OSDT examples work is that they are started in a different thread; because of the thread execution order the start intermittently fails because of the problem below.

      In DefaultMuleClient.start():

      public synchronized void start() throws MuleException
      if (!isStarted())
      if (getSecurityManager() == null)

      { throw new MuleRuntimeException(CoreMessages.objectIsNull("securityManager")); }

      if (getQueueManager() == null)

      { throw new MuleRuntimeException(CoreMessages.objectIsNull("queueManager")); }


      The lifecycleManager.checkPhase() call should be inside of the !isStarted().

      What's happening in my tests is that I spawn a thread that starts up MuleClients which causes a the MuleContext to start. Remembering the stack trace in the previous message, this thread is called by the setUp() method in the AbstractMuleTestCase. If the thread starts and gets into the synchronized block of the above start() method, then the main thread will block there while the lengthy startup process is happening. Then the main thread will die because it will fail the checkPhase() call.


        No work has yet been logged on this issue.


          • Assignee:
            Ross Mason
            Francis Upton
          • Votes:
            1 Vote for this issue
            4 Start watching this issue


            • Created: