title: Cucumber dependency injection @Scope("cucumber-glue") is not registered
body: <p><strong>Problem:</strong> I am trying to have a number of classes scoped once for every scenario of my cucumber parallel tests, as of right now I am getting data contamination because the data in which these 3 objects manage is leaking into subsequent scenarios.</p>
  
  <p>Firstly, I am configuring spring using the following dependencies:</p>
  
  <p><strong>Spring version: 4.3.16.RELEASE,</strong>
  <strong>Cucumber version: 2.4.0</strong></p>
  
  <pre><code>  &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-core --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-context --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
              &lt;artifactId&gt;cucumber-core&lt;/artifactId&gt;
              &lt;version&gt;${cucumber.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
              &lt;artifactId&gt;cucumber-java8&lt;/artifactId&gt;
              &lt;version&gt;${cucumber.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.sql2o/sql2o --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.sql2o&lt;/groupId&gt;
              &lt;artifactId&gt;sql2o&lt;/artifactId&gt;
              &lt;version&gt;${sql20.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
              &lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;
              &lt;version&gt;${cucumber.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
              &lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;
              &lt;version&gt;${cucumber.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
              &lt;artifactId&gt;cucumber-spring&lt;/artifactId&gt;
              &lt;version&gt;${cucumber.version}&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>my world is relatively simple, all scenario data resides in these services and the world looks like so:</p>
  
  <pre><code>@Slf4j
  public class CucumberWorld {
  
      @Autowired
      private DataBaseHelper databaseHelper;
  
      @Autowired
      private Driver driver;
  
      @Autowired @Getter
      private FolderDataService folderDataService;
  
      @Autowired @Getter
      private UserDataService userDataService;
  
      @Autowired @Getter
      private AccountDataService accountDataService;
  </code></pre>
  
  <p>Other things to note, I have a <code>Driver</code> object which is a bean, and a singleton.  I have various <code>PageObjects</code> which are again, all singleton.  My Page objects on 2-3 occassions contain an @Autowired instance variable for these services, for example:</p>
  
  <pre><code>@Slf4j
  public class LoginPage extends AbstractBasePageObject {
  
      @Getter
      @Autowired
      private CookieModalComponent cookieModal;
      @Getter
      @Autowired
      private RegistrationModalComponent registrationModal;
      @Getter
      @Autowired
      private PrivacyNoticeModalComponent privacyModal;
      @Autowired
      AccountDataService accountDataService;
  </code></pre>
  
  <p>The Driver + PageObjects should be singletons and last throughout the entire test lifecycle, with these services being reset for each individual scenario.</p>
  
  <p>When I build my bean like so:</p>
  
  <pre><code>@Bean
  @Scope("cucumber-world")
  public AccountDataService accountDataService() {
  return new AccountDataService();
  }
  </code></pre>
  
  <p>I receive the following:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'world': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: No Scope registered for scope name 'cucumber-world'
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
      ... 29 more
  Caused by: java.lang.IllegalStateException: No Scope registered for scope name 'cucumber-world'
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:343)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
      ... 40 more
  </code></pre>
  
  <p>here is my spring configuration class:</p>
  
  <pre><code>@Configuration
  @Slf4j
  public class ProductSpringConfiguration extends SpringConfig {
  
      @Bean
      public FolderDataService folderDataService() {
          return new FolderDataService();
      }
  
      @Bean
      public AccountDataService accountDataService() {
          return new AccountDataService();
      }
  
  @Bean
  public LoginPage loginPage() {
      return new LoginPage(driver());
  }
  </code></pre>
  
  <p>Both the Driver bean and the parent spring config class are inherited from a common dependency, the Driver bean is a simple singleton like so:</p>
  
  <pre><code>@Bean
  public Driver driver() {
   return new Driver();
  }
  </code></pre>