title: Using Spring StateMachine in an EJB container
body: <p>I'm trying to use Spring's state machine library inside of a JavaEE application running in a container to manage instances of a class named <code>RunInfo</code>. But I'm not sure how to integrate the two together.</p>
  <p>I tried adding the following dependencies:</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-autoconfigure&lt;/artifactId&gt;
      &lt;version&gt;2.2.11.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.statemachine&lt;/groupId&gt;
      &lt;artifactId&gt;spring-statemachine-core&lt;/artifactId&gt;
      &lt;version&gt;2.4.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
      &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
      &lt;version&gt;5.7.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>on spring-boot-autoconfigure and then adding the following configuration class:</p>
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @ComponentScan(basePackages = {&quot;com.ourdomain&quot;})
  public class StateConfiguration {}
  </code></pre>
  <p>I then wrote a simple state machine configuration:</p>
  <pre><code>@Configuration
  @EnableStateMachine(name = &quot;runInfoStateMachine&quot;)
  public class RunInfoStateMachineConfiguration extends EnumStateMachineConfigurerAdapter&lt;RunInfoState, RunInfoEvent&gt; {
  </code></pre>
  <p>and state handler:</p>
  <pre><code>@Component
  public class RunInfoStateHandler extends LifecycleObjectSupport {
  // ...
  @Autowired private StateMachine&lt;RunInfoState, RunInfoEvent&gt; stateMachine;
  }
  </code></pre>
  <p>based on another project that I manage (which is a pure Spring Boot app).</p>
  <p>The state handler is created, but the state machine reference is never injected; i.e., <code>stateMachine</code> in the above code is always null.</p>
  <p>How does one integrate the Spring StateMachine framework into an EJB application?</p>