title: ClassNotFound org/springframework/beans/factory/NoUniqueBeanDefinitionException
body: <p>I'm trying to create a Spring-Hibernate application in which I get this following exception with the root cause</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException
      java.lang.Class.getDeclaredMethods0(Native Method)
      java.lang.Class.privateGetDeclaredMethods(Unknown Source)
      java.lang.Class.getDeclaredMethods(Unknown Source)
      org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:159)
      org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:106)
      org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87)
      org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:233)
      org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203)
      org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:617)
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
      org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
      org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
      org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
      org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
      org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
      org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
      javax.servlet.GenericServlet.init(GenericServlet.java:158)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
      org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>I am sure that I have properly configured everything.
  I am using @autowired inside my controller (Annotation based) and also in my ServiceImpl classes.</p>
  
  <p>Here is my controller.</p>
  
  <pre><code>package com.sarvika.sqexch;
  
  import java.text.DateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  import java.util.Locale;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  import com.sarvika.sqexch.beans.QuestionBean;
  import com.sarvika.sqexch.model.Question;
  import com.sarvika.sqexch.service.QuestionService;
  
  /**
   * Handles requests for the application home page.
   */
  @Controller
  public class HomeController {
  
      @Autowired
      private QuestionService questionService;
  
      private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
  
      /**
       * Simply selects the home view to render by returning its name.
       */
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String home(Locale locale, Model model) {
          logger.info("Welcome home! The client locale is {}.", locale);
  
          Date date = new Date();
          DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  
          String formattedDate = dateFormat.format(date);
  
          model.addAttribute("serverTime", "&lt;font color=\"red\"&gt;"+formattedDate+"&lt;/font&gt;" );
          model.addAttribute("questions", prepareListofBean(questionService.listQuestions()));
  
          return "home";
      }
  
      private List&lt;QuestionBean&gt; prepareListofBean(List&lt;Question&gt; questions){  
          List&lt;QuestionBean&gt; beans = null;  
          if(questions != null &amp;&amp; !questions.isEmpty()){  
              beans = new ArrayList&lt;QuestionBean&gt;();  
              QuestionBean bean = null;  
              for(Question question : questions){  
                  bean = new QuestionBean();  
                  bean.setId(question.getId());  
                  bean.setParent(question.getParent());  
                  bean.setTitle(question.getTitle());  
                  bean.setDescription(question.getDescription());  
                  bean.setAsker_id(question.getAsker_id());  
                  bean.setAccepted(question.getAccepted());
                  beans.add(bean);  
              }  
          }  
          return beans;  
      }  
  
  }
  </code></pre>
  
  <p>And my context configuration XML</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt;
  
      &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
      &lt;annotation-driven /&gt;
  
      &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --&gt;
      &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --&gt;
      &lt;context:property-placeholder location="/resources/database.properties" /&gt;
      &lt;tx:annotation-driven transaction-manager="hibernateTransactionManager" /&gt;
  
      &lt;beans:bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"&gt;  
          &lt;beans:property name="driverClassName" value="${database.driver}" /&gt; 
          &lt;beans:property name="url" value="${database.url}" /&gt;
          &lt;beans:property name="username" value="${database.user}" /&gt;
          &lt;beans:property name="password" value="${database.password}" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory"&gt;  
          &lt;beans:property name="dataSource" ref="dataSource" /&gt;  
          &lt;beans:property name="annotatedClasses"&gt;  
              &lt;beans:list&gt;  
                  &lt;beans:value&gt;com.dineshonjava.model.Employee&lt;/beans:value&gt;  
              &lt;/beans:list&gt;  
          &lt;/beans:property&gt;  
          &lt;beans:property name="hibernateProperties"&gt;  
              &lt;beans:props&gt;  
                  &lt;beans:prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/beans:prop&gt;  
                  &lt;beans:prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/beans:prop&gt;  
                  &lt;beans:prop key="hibernate.hbm2ddl.auto"&gt;${hibernate.hbm2ddl.auto}&lt;/beans:prop&gt;     
              &lt;/beans:props&gt;  
          &lt;/beans:property&gt;  
      &lt;/beans:bean&gt;
  
      &lt;beans:bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" id="hibernateTransactionManager"&gt;  
          &lt;beans:property name="sessionFactory" ref="sessionFactory"&gt;&lt;/beans:property&gt;  
      &lt;/beans:bean&gt;
  
      &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --&gt;
      &lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;beans:property name="suffix" value=".jsp" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;context:component-scan base-package="com.sarvika.sqexch" /&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>I'm pretty sure that I am doing something wrong. It would be great if one of you guys ca correct me... :D</p>
  
  <p>EDIT:
  I am using Maven. Here is the pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.sarvika&lt;/groupId&gt;
      &lt;artifactId&gt;sqexch&lt;/artifactId&gt;
      &lt;name&gt;HelloSpring&lt;/name&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0.0-BUILD-SNAPSHOT&lt;/version&gt;
      &lt;properties&gt;
          &lt;java-version&gt;1.6&lt;/java-version&gt;
          &lt;org.springframework-version&gt;3.1.1.RELEASE&lt;/org.springframework-version&gt;
          &lt;org.aspectj-version&gt;1.6.10&lt;/org.aspectj-version&gt;
          &lt;org.slf4j-version&gt;1.6.6&lt;/org.slf4j-version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;!-- Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;!-- Exclude Commons Logging in favor of SLF4j --&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                   &lt;/exclusion&gt;
              &lt;/exclusions&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;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Spring Aspects --&gt;
          &lt;dependency&gt; 
               &lt;groupId&gt;org.springframework&lt;/groupId&gt; 
               &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt; 
               &lt;version&gt;3.1.2.RELEASE&lt;/version&gt; 
          &lt;/dependency&gt;
  
          &lt;!-- Spring-orm --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Spring JDBC --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;4.2.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- spring-tx --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- org.hibernate --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-search&lt;/artifactId&gt;
              &lt;version&gt;3.3.0.CR2&lt;/version&gt;
          &lt;/dependency&gt;       
  
          &lt;!-- javax Persistence --&gt;  
          &lt;dependency&gt;
             &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
             &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
             &lt;version&gt;1.0.2&lt;/version&gt;
             &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;       
  
          &lt;!-- AspectJ --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
              &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
          &lt;/dependency&gt;   
  
          &lt;!-- Logging --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;1.2.15&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.mail&lt;/groupId&gt;
                      &lt;artifactId&gt;mail&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                      &lt;artifactId&gt;jms&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- @Inject --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Test --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.7&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;        
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.9&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;additionalProjectnatures&gt;
                          &lt;projectnature&gt;org.springframework.ide.eclipse.core.springnature&lt;/projectnature&gt;
                      &lt;/additionalProjectnatures&gt;
                      &lt;additionalBuildcommands&gt;
                          &lt;buildcommand&gt;org.springframework.ide.eclipse.core.springbuilder&lt;/buildcommand&gt;
                      &lt;/additionalBuildcommands&gt;
                      &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                      &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
                      &lt;showWarnings&gt;true&lt;/showWarnings&gt;
                      &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;org.test.int1.Main&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>