title: Spring: nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
body: <p><strong>Stack trace:</strong></p>
  
  <pre><code>Oct 24, 2014 8:12:04 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
  INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@50df2e: startup date [Fri Oct 24 08:12:04 IST 2014]; root of context hierarchy
  Oct 24, 2014 8:12:05 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from class path resource [knights-aop.xml]
  Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [knights-aop.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at com.java.spring.SpringDemo.main(SpringDemo.java:12)
  Caused by: java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
      at org.springframework.aop.config.ConfigBeanDefinitionParser.getAdviceClass(ConfigBeanDefinitionParser.java:410)
      at org.springframework.aop.config.ConfigBeanDefinitionParser.createAdviceDefinition(ConfigBeanDefinitionParser.java:366)
      at org.springframework.aop.config.ConfigBeanDefinitionParser.parseAdvice(ConfigBeanDefinitionParser.java:332)
      at org.springframework.aop.config.ConfigBeanDefinitionParser.parseAspect(ConfigBeanDefinitionParser.java:227)
      at org.springframework.aop.config.ConfigBeanDefinitionParser.parse(ConfigBeanDefinitionParser.java:115)
      at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
      ... 14 more
  </code></pre>
  
  <p>config xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;
  
    &lt;bean id="knight" class="com.java.spring.BraveKnight"&gt;
      &lt;constructor-arg ref="quest" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="quest" class="com.java.spring.ResqueDamselQuest" /&gt;
  
    &lt;bean id="minstrel" 
       class="com.java.spring.Minstrel" /&gt; &lt;!--&lt;co id="co_minstrel_bean"/&gt;--&gt;
  
    &lt;aop:config&gt;
      &lt;aop:aspect ref="minstrel"&gt;
  
        &lt;aop:pointcut id="embark" 
            expression="execution(* *.embarkOnQuest(..))" /&gt; &lt;!--&lt;co id="co_define_pointcut"/&gt;--&gt;
  
        &lt;aop:before pointcut-ref="embark"
                    method="singBeforeQuest"/&gt;    &lt;!--&lt;co id="co_minstrel_before_advice"/&gt;--&gt;
  
        &lt;aop:after pointcut-ref="embark"
                   method="singAfterQuest"/&gt;     &lt;!--&lt;co id="co_minstrel_after_advice"/&gt;--&gt;
  
      &lt;/aop:aspect&gt;
    &lt;/aop:config&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My main class:</p>
  
  <pre><code>public class SpringDemo {
      public static void main(String[] args) {
          final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("knights-aop.xml");
          final Knight braveKnight = (Knight) applicationContext.getBean("knight");
          braveKnight.embarkOnQuest();
      }
  }
  </code></pre>
  
  <p>I also tried adding: aopalliance.jar &amp; aopalliance-alpha1.jar individually and together but the error won't go away.</p>
  
  <p>There are similar questions here on SO: <a href="https://stackoverflow.com/q/16458816/768894">spring nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice</a></p>
  
  <p><strong>###########EDIT###########Update: Other classes in the project##</strong><br>
  Minstrel.java</p>
  
  <pre><code>package com.java.spring;
  
      public class Minstrel {
          public void singBeforeQuest(){
              System.out.println("Fa la la Theknight is so brave!");
          }
          public void singAfterQuest(){
              System.out.println(
                      "Tee hee he The brave knight did embark on a quest!");
          }
      }
  </code></pre>
  
  <p>BraveKnight.java</p>
  
  <pre><code>package com.java.spring;
  
  public class BraveKnight implements Knight {
      private Quest quest;
  
      BraveKnight(Quest quest) {
          this.quest = quest;
      }
  
      @Override
      public void embarkOnQuest() {
          quest.embark();
      }
  }
  </code></pre>
  
  <p>RescueDamselQuest.java</p>
  
  <pre><code>package com.java.spring;
  
      public class RescueDamselQuest implements Quest {
  
          @Override
          public void embark() {
              System.out.println("Damsel rescue quest is on.");
          }
      }
  </code></pre>
  
  <p><br>I am using Spring 3.2<br>
  <strong>##################EDIT2##################</strong><br>I am not using Maven. Please don't provide Maven related solution unless Spring AOP is impossible without it.
  <br><strong>Project Snap:</strong><br><img src="https://i.stack.imgur.com/UnZTU.jpg" alt="enter image description here">
  <br>Inside SPRING LIBRARY I have all the jar that got downloaded with Spring. Is it possible that some spring specific jar conflicting with aopalliance jar?
  <br><br><strong>If anyone has some similar &amp; simple working example without Maven, please provide it.</strong><br><br>
  Thanks<br>~Mohit</p>