Mule
  1. Mule
  2. MULE-4589

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

    Details

    • 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:
      None
    • User impact:
      High
    • 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

      Description

      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(GenericLifecycleManager.java:174)
      at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:159)
      at org.mule.tck.AbstractMuleTestCase.setUp(AbstractMuleTestCase.java:409)
      at org.mule.tck.AbstractMuleTestCase.runBare(AbstractMuleTestCase.java:291)
      at org.mule.tck.AbstractMuleTestCase.run(AbstractMuleTestCase.java:270)

      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
      {
      lifecycleManager.checkPhase(Startable.PHASE_NAME);
      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.

        Activity

        Hide
        Francis Upton added a comment -

        See also MULE-4590.

        Show
        Francis Upton added a comment - See also MULE-4590 .
        Show
        Daniel Feist added a comment - 2.1.x: http://fisheye.codehaus.org/changelog/mule/branches/mule-2.1.x?cs=15959 2.2.x: http://fisheye.codehaus.org/changelog/mule/branches/mule-2.2.x?cs=15960 3.x: http://fisheye.codehaus.org/changelog/mule/branches/mule-3.x?cs=15961
        Hide
        Geetha Vallabhaneni added a comment -

        When deploying under TomCat, Mule3.0 (Milestone 4) throws the following exception:

        a.lang.IllegalStateException: Already in lifecycle phase 'start', cannot fire
        e same phase twice
        at org.mule.lifecycle.LifecycleManagerSupport.checkPhase(LifecycleManage
        pport.java:103)

        It is the same bug as this one which was fixed in in 2.2.3:

        http://www.mulesoft.org/jira/browse/MULE-4589

        the synchronization primitives around the start routine have not made it into 3.0. Here is the thread with more information.

        http://forums.mulesoft.org/message.jspa?messageID=10181#10181

        Show
        Geetha Vallabhaneni added a comment - When deploying under TomCat, Mule3.0 (Milestone 4) throws the following exception: a.lang.IllegalStateException: Already in lifecycle phase 'start', cannot fire e same phase twice at org.mule.lifecycle.LifecycleManagerSupport.checkPhase(LifecycleManage pport.java:103) It is the same bug as this one which was fixed in in 2.2.3: http://www.mulesoft.org/jira/browse/MULE-4589 the synchronization primitives around the start routine have not made it into 3.0. Here is the thread with more information. http://forums.mulesoft.org/message.jspa?messageID=10181#10181
        Hide
        Geetha Vallabhaneni added a comment -

        Assigning this to Ross as he is working on lifecycle issues (and asked me to do so).

        Show
        Geetha Vallabhaneni added a comment - Assigning this to Ross as he is working on lifecycle issues (and asked me to do so).

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development