title: java.lang.NoSuchMethodError with @PreAuthorize annotation
body: <p>I use Spring Security 3 with Tomcat 7. My http tag definition is like that:</p>
  
  <pre><code>&lt;http auto-config="false" disable-url-rewriting="true" 
  entry-point-ref="loginUrlAuthenticationEntryPoint" use-expressions="true"&gt;
  ...
  </code></pre>
  
  <p>However when I want to use method based security as like:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET)
  @PreAuthorize("hasRole('ROLE_USER')")
  public
  @ResponseBody
  List&lt;Lenhos&gt; getAllLenhosInJSON() {
      return new ArrayList&lt;Lenhos&gt;(lenhoMap.values());
  }
  </code></pre>
  
  <p>and run my application I get a 404 not found error at web side and the error is as follows at Tomcat:</p>
  
  <pre><code>ERROR ContextLoader:220 - Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LenhoConf' defined in file [/web-core/target/web-core/WEB-INF/classes/com/almen/donho/webcore/controller/LenhoConf.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:636)
  Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at net.sf.cglib.core.DebuggingClassWriter.&lt;init&gt;(DebuggingClassWriter.java:47)
      at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
      at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
      at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
      at net.sf.cglib.proxy.Enhancer.&lt;clinit&gt;(Enhancer.java:69)
      at org.springframework.aop.framework.Cglib2AopProxy.createEnhancer(Cglib2AopProxy.java:228)
      at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:170)
      at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      ... 19 more
  </code></pre>
  
  <p>Error occured when I added <code>@PreAuthorize("hasRole('ROLE_USER')")</code>. What may be the cause of that error?</p>
  
  <p><strong>PS: 1</strong> My pom.xml file as follows:</p>
  
  <pre><code>&lt;properties&gt;
      &lt;spring.version&gt;3.0.5.RELEASE&lt;/spring.version&gt;
  &lt;/properties&gt;
  
  &lt;!-- Spring 3 dependencies --&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-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-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring security dependencies --&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;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Jackson JSON Mapper --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.7.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;build&gt;
      &lt;finalName&gt;web-core&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I don't use hibernate at my project however I import some modules(I use Intellij IDEA) into my application and they use. There is nothing runs related to Hibernate when I run my application. I am new to Spring.</p>
  
  <p><strong>PS 2:</strong> 
  This is my dependency tree:</p>
  
  <pre><code>[INFO] [dependency:tree {execution: default-cli}]
  [INFO] xxx:web-core:war:1.0-SNAPSHOT
  [INFO] +- :xxx-yyy:jar:1.0-SNAPSHOT:compile
  [INFO] |  +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
  [INFO] |  \- org.hibernate:hibernate-entitymanager:jar:3.6.6.Final:compile
  [INFO] |     \- cglib:cglib:jar:2.2:compile
  [INFO] \- xxx:zzz:jar:1.0-SNAPSHOT:compile
  [INFO]    \- org.hibernate:hibernate:jar:3.2.7.ga:compile
  [INFO]       +- asm:asm-attrs:jar:1.5.3:compile
  [INFO]       \- asm:asm:jar:1.5.3:compile
  </code></pre>
  
  <p>yyy and zzz other modules of my application that I use.</p>
  
  <p><strong>PS 3:</strong>
  My new dependency tree:</p>
  
  <pre><code>[INFO] xxx:web-core:war:1.0-SNAPSHOT
  [INFO] \- xxx-yyy:jar:1.0-SNAPSHOT:compile
  [INFO]    +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
  [INFO]    +- org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga:compile
  [INFO]    |  \- org.hibernate:hibernate:jar:3.2.1.ga:compile
  [INFO]    |     +- asm:asm-attrs:jar:1.5.3:compile
  [INFO]    |     \- asm:asm:jar:1.5.3:compile
  [INFO]    \- org.hibernate:hibernate-entitymanager:jar:3.6.6.Final:compile
  [INFO]       \- cglib:cglib:jar:2.2:compile
  </code></pre>