title: Springframework Failed to parse configuration class on a controller
body: <p>I am working on a j2ee project with eclipse, maven and spring. All is going quite fine except a weird and annoying behavior i can't resolve...</p>
  
  <p>Let's begin with the stacktrace : </p>
  
  <pre><code>[localhost-startStop-1] WARN org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
  org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.lttd.controller.FichiersController]; nested exception is
  java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
  at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:172)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
  at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
  at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:50)
  at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82)
  at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
  at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:77)
  at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:587)
  at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getMemberClasses(ConfigurationClassParser.java:749)
  at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:313)
  at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:245)
  at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:228)
  at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:186)
  at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165)
  ... 18 more
  [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
  org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.lttd.controller.FichiersController]; nested exception is java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:172)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
      at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
      at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:50)
      at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82)
      at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
      at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:77)
      at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:587)
      at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getMemberClasses(ConfigurationClassParser.java:749)
      at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:313)
      at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:245)
      at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:228)
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:186)
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165)
      ... 18 more
  juin 17, 2015 10:42:55 AM org.apache.catalina.core.StandardContext listenerStart
  GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.lttd.controller.FichiersController]; nested exception is java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:172)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.FileNotFoundException: class path resource [com/lttd/controller/FichiersController$1.class] cannot be opened because it does not exist
      at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
      at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:50)
      at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82)
      at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
      at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:77)
      at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:587)
      at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getMemberClasses(ConfigurationClassParser.java:749)
      at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:313)
      at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:245)
      at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:228)
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:186)
      at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165)
      ... 18 more 
  </code></pre>
  
  <p>After some search on google i found it can be related to a classpath problem, so there is my Build path (can't post pictures ...):</p>
  
  <p>In source folder build path :
      intranetLTTD/src/main/java
      Included : All
      Excluded : none</p>
  
  <p>and my project treeview :</p>
  
  <p>Java Ressources
        - src/main/java
             -com.lttd.controller
                  -FichiersController</p>
  
  <p>So it don't seems to be a classpath issue.</p>
  
  <p>I also found on google that the "$1.class" means its an anonymous class... why not but i don't make it from my own, ( i don't even know how to make it for a controller ).</p>
  
  <p>This error is happening when i make any change in my FichiersController ( like declare a variable ) but also when i make any change in a controller i created after my FichiersController, but not in the ones i created before.</p>
  
  <p>I found a workaround to still be able to run the project ( and it's a weird workaround ) : after making a change, i have to change in one of my method of the FichiersController : </p>
  
  <pre><code>TypeFichier fileType = TypeFichier.valueOf(fileTypeString);
  switch(fileType)
  </code></pre>
  
  <p>to :</p>
  
  <pre><code>switch(TypeFichier.valueOf(fileTypeString))
  </code></pre>
  
  <p>Or reverse</p>
  
  <pre><code>switch(TypeFichier.valueOf(fileTypeString))
  </code></pre>
  
  <p>to </p>
  
  <pre><code>switch(fileType) 
  </code></pre>
  
  <p>And in my dispatcher-servlet.xml i have :</p>
  
  <pre><code>&lt;context:component-scan base-package="com.lttd" /&gt;
  </code></pre>
  
  <p>I hope i've gave all you need to help me find out whats happening, and how to resolve it. Don't hesitate to ask for further informations.</p>
  
  <p>Thanks for your help.</p>