title: java.lang.NoClassDefFoundError when marking a jar as provided
body: <p>I have the follwing dependency in my webapp:  </p>
  
  <pre><code>&lt;!-- swagger --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.mangofactory&lt;/groupId&gt;
      &lt;artifactId&gt;swagger-springmvc&lt;/artifactId&gt;
      &lt;version&gt;${version.swagger.springmvc}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I want to reduce the size of the war file so I marked the swagger jar as provided:</p>
  
  <pre><code>&lt;!-- swagger --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.mangofactory&lt;/groupId&gt;
      &lt;artifactId&gt;swagger-springmvc&lt;/artifactId&gt;
      &lt;version&gt;${version.swagger.springmvc}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I added the swagger jar to tomcat's common lib folder so it should be provided by tomcat during runtime, but when i try to deply the app I got this exception:</p>
  
  <pre><code>java.lang.IllegalStateException: Cannot load configuration class: com.mangofactory.swagger.configuration.DocumentationConfig
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:368)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:244)
  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
  at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
  at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
  at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
  at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
  at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
  at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  at javax.servlet.GenericServlet.init(GenericServlet.java:158)
  at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1279)
  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1192)
  at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
  at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
  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:744)
  Caused by: java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
  at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
  at java.lang.Class.getDeclaredMethods(Class.java:1962)
  at org.springframework.cglib.core.ReflectUtils.addAllMethods(ReflectUtils.java:348)
  at org.springframework.cglib.proxy.Enhancer.getMethods(Enhancer.java:421)
  at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:456)
  at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
  at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
  at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
  at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
  at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118)
  at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:92)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:358)
  ... 23 more
  Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.TypeResolver
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
  ... 36 more
  </code></pre>
  
  <p>I notice that the problem is comming from the org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses but i have all the spring jar required declared in my pom without the provided scope also when
  running the webapp without the provided scope it work fine any idea?</p>