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

MuleSoft JIRA | Kamil Zych | 6 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    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.

    MuleSoft JIRA | 7 years ago | Francis Upton
    java.lang.IllegalStateException: Phase 'start' has already been executed
  2. 0

    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.

    MuleSoft JIRA | 6 years ago | Kamil Zych
    java.lang.IllegalStateException: Phase 'start' has already been executed
  3. 0

    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.

    MuleSoft JIRA | 7 years ago | Francis Upton
    java.lang.IllegalStateException: Phase 'start' has already been executed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    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.

    MuleSoft JIRA | 6 years ago | Kamil Zych
    java.lang.IllegalStateException: Phase 'start' has already been executed

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Phase 'start' has already been executed

      at org.mule.lifecycle.GenericLifecycleManager.checkPhase()
    2. Mule Core
      DefaultMuleContext.start
      1. org.mule.lifecycle.GenericLifecycleManager.checkPhase(GenericLifecycleManager.java:174)
      2. org.mule.DefaultMuleContext.start(DefaultMuleContext.java:159)
      2 frames
    3. Mule Functional Test Framework (TCK)
      AbstractMuleTestCase.run
      1. org.mule.tck.AbstractMuleTestCase.setUp(AbstractMuleTestCase.java:409)
      2. org.mule.tck.AbstractMuleTestCase.runBare(AbstractMuleTestCase.java:291)
      3. org.mule.tck.AbstractMuleTestCase.run(AbstractMuleTestCase.java:270)
      3 frames