title: Spring configurartion and Component scan break when trying to create tests
body: <p>I have a Spring app and am trying to setup the tests but I cant get the configuration to work when running mvn test. </p>
  
  <p>The entire thing works perfectly fine on build and when deployed. </p>
  
  <p>The error i'm getting doesn't really (that I can tell) tell me much information. </p>
  
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
          at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
          at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123)
          at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
          at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
          at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
          at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
          at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
          at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
          at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
          at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
          at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
          at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
          at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
          at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
  Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [c:my\filepath\model\persistence\MyClass.class]; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:454)
          at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)
          at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:276)
          at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
          at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:290)
          at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
          at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:587)
          at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:305)
          at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
          at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:587)
          at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:305)
          at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
          at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)
          at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)
          at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:325)
          at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242)
          at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
          at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
          at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:129)
          at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:61)
          at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)
          at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)
          at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
          at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
          ... 31 more
  Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          at java.util.ArrayList.rangeCheck(ArrayList.java:657)
          at java.util.ArrayList.get(ArrayList.java:433)
          at org.springframework.core.annotation.AnnotationTypeMappings.get(AnnotationTypeMappings.java:165)
          at org.springframework.core.annotation.TypeMappedAnnotation.of(TypeMappedAnnotation.java:638)
          at org.springframework.core.annotation.MergedAnnotation.of(MergedAnnotation.java:596)
          at org.springframework.core.type.classreading.MergedAnnotationReadingVisitor.visitEnd(MergedAnnotationReadingVisitor.java:96)
          at org.springframework.asm.ClassReader.readElementValues(ClassReader.java:2775)
          at org.springframework.asm.ClassReader.accept(ClassReader.java:572)
          at org.springframework.asm.ClassReader.accept(ClassReader.java:400)
          at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:50)
          at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
          at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
          at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
          ... 56 more
  </code></pre>
  
  <p>What could be causing this? </p>
  
  <p>Contents of MyClass...</p>
  
  <pre><code>@Entity
  @Table(name = "MyClass")
  public class MyClass implements Serializable {
      private static final long serialversionUID = 1L;
  
      @Id
      @Column(name = "ID")
      private Long id; 
      @JsonBackReference
      @OneToMany(fetch = FetchType.LAZY)
      @JoinColumn(name = "OUID", insertable=false, updateable=false);
      private Set&lt;AnotherClass&gt; another = new HasSet&lt;AnotherClass&gt;();
      //A bunch of other 'regular' columns and fields
      public Myclass(){}
      //hash method and toString
  
  
  
  }
  </code></pre>