title: No unique bean of type is defined, expected single bean but found 0
body: <p>Exception which i've stated is certainly asked before. But before you mark this question as duplicate, please read the complete problem statement. As i've already tried out all other solutions available for the same problem but unfortunately neither of them hit the bulls-eye.
  I'll start with the complete stack trace which is as follows :-</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.support.DefaultListableBeanFactory@5686a031
    11:27:18,529 ERROR [org.springframework.web.servlet.DispatcherServlet]
    (MSC service thread 1-6) Context initialization failed:
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'UserSessionDao': Injection of persistence
    dependencies failed; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    unique bean of type [javax.persistence.EntityManagerFactory] is
    defined: expected single bean but found 0     at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    javax.servlet.GenericServlet.init(GenericServlet.java:242)
    [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]  at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)
    [jbossweb-7.0.13.Final.jar:]  at
    org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
    [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]    at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    [rt.jar:1.7.0_67]     at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    [rt.jar:1.7.0_67]     at java.lang.Thread.run(Thread.java:745)
    [rt.jar:1.7.0_67] Caused by:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    unique bean of type [javax.persistence.EntityManagerFactory] is
    defined: expected single bean but found 0     at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:537)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  ... 27 more</p>
    
    <p>11:27:18,563 ERROR
    [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/AltSurvey]]
    (MSC service thread 1-6) StandardWrapper.Throwable:
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'UserSessionDao': Injection of persistence
    dependencies failed; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    unique bean of type [javax.persistence.EntityManagerFactory] is
    defined: expected single bean but found 0     at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    javax.servlet.GenericServlet.init(GenericServlet.java:242)
    [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]  at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)
    [jbossweb-7.0.13.Final.jar:]  at
    org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
    [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]    at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    [rt.jar:1.7.0_67]     at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    [rt.jar:1.7.0_67]     at java.lang.Thread.run(Thread.java:745)
    [rt.jar:1.7.0_67] Caused by:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    unique bean of type [javax.persistence.EntityManagerFactory] is
    defined: expected single bean but found 0     at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:537)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  ... 27 more</p>
    
    <p>11:27:18,615 ERROR
    [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/AltSurvey]]
    (MSC service thread 1-6) Servlet /AltSurvey threw load() exception:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    unique bean of type [javax.persistence.EntityManagerFactory] is
    defined: expected single bean but found 0     at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:537)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
    [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]    at
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]  at
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]   at
    javax.servlet.GenericServlet.init(GenericServlet.java:242)
    [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]  at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)
    [jbossweb-7.0.13.Final.jar:]  at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)
    [jbossweb-7.0.13.Final.jar:]  at
    org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
    [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]    at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at
    org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    [rt.jar:1.7.0_67]     at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    [rt.jar:1.7.0_67]     at java.lang.Thread.run(Thread.java:745)
    [rt.jar:1.7.0_67]</p>
    
    <p>11:27:18,769 INFO  [org.jboss.web] (MSC service thread 1-6)
    JBAS018210: Registering web context: /AltSurvey 11:27:18,803 INFO 
    [org.jboss.as] (MSC service thread 1-6) JBAS015951: Admin console
    listening on <a href="http://127.0.0.1:9990" rel="nofollow">http://127.0.0.1:9990</a> 11:27:18,803 INFO  [org.jboss.as]
    (MSC service thread 1-6) JBAS015874: JBoss AS 7.1.1.Final "Brontes"
    started in 59812ms - Started 466 of 565 services (81 services are
    passive or on-demand) 11:27:19,077 INFO  [org.jboss.as.server]
    (DeploymentScanner-threads - 2) JBAS018559: Deployed "AltSurvey.war"</p>
  </blockquote>
  
  <p>please note even though i'm getting exception while deployment, but still the deploy-able is being deployed.</p>
  
  <p>Now as per one of the solutions i've even configured entity manager. Please find my hibernateJpaConfig.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"
      xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
                  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context-3.0.xsd
                  http://www.springframework.org/schema/tx
                  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                  http://www.springframework.org/schema/aop
                  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
      default-autowire="byName"&gt;
  
      &lt;bean id="surveyDataSource" class="org.apache.commons.dbcp.BasicDataSource"
          scope="singleton" destroy-method="close"&gt;
          &lt;property name="driverClass" value="${driver}" /&gt;
          &lt;property name="jdbcUrl" value="${url}" /&gt;
          &lt;property name="user" value="${user}" /&gt;
          &lt;property name="password" value="${password}" /&gt;
          &lt;property name="initialPoolSize" value="10" /&gt;
          &lt;property name="minPoolSize" value="5" /&gt;
          &lt;property name="maxPoolSize" value="20" /&gt;
          &lt;property name="maxIdleTime" value="5" /&gt;
          &lt;property name="autoCommitOnClose" value="false" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory" depends-on="surveyDataSource"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="surveyDataSource" /&gt;
          &lt;property name="persistenceXmlLocation" value="classpath:persistence.xml" /&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>But this didn't work out. After that again as per one of the solutions i tried with adding below code snippet :-</p>
  
  <p>
      Spring OpenEntityManagerInViewFilter
      org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
  </p>
  
  <p>in my web.xml. My Web.xml is as follows :-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;!-- Document : web.xml Created on : 21 January, 2016, 11:17 AM Author : 
      Vaibhav kashyap Description: This file will contain the main servlet mappings 
      and all the app configuration entry points. --&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0" metadata-complete="true"&gt;
      &lt;context-param&gt;
          &lt;description&gt;Spring configuration file&lt;/description&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:ApplicationContext.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;persistence-unit-ref&gt;
          &lt;description&gt;
              Persistence unit description.
          &lt;/description&gt;
          &lt;persistence-unit-ref-name&gt;persistence/TalentPactFormEngine_New&lt;/persistence-unit-ref-name&gt;
          &lt;persistence-unit-name&gt;TalentPactFormEngine_New&lt;/persistence-unit-name&gt;
      &lt;/persistence-unit-ref&gt;
  
      &lt;listener&gt;
          &lt;description&gt;Spring Loader&lt;/description&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.security.web.session.HttpSessionEventPublisher&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;Spring OpenEntityManagerInViewFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;rest&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;!-- &lt;filter&gt; &lt;filter-name&gt;filterChainProxy&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; 
          &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;filterChainProxy&lt;/filter-name&gt; &lt;url-pattern&gt;*&lt;/url-pattern&gt; 
          &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt; &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; &lt;/filter-mapping&gt; --&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;rest&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.js&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.css&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.gif&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.png&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/images/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;default&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/fonts/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;mime-mapping&gt;
          &lt;extension&gt;json&lt;/extension&gt;
          &lt;mime-type&gt;application/json&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;session-config&gt;
          &lt;tracking-mode&gt;COOKIE&lt;/tracking-mode&gt;
      &lt;/session-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>But this also didn't work out. Next solution i tried with </p>
  
  <blockquote>
    <p>context:annotation-config</p>
  </blockquote>
  
  <p>enabling this through my Application context which is as follows :-</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:context="http://www.springframework.org/schema/context"
      xmlns:p="http://www.springframework.org/schema/p" xmlns:sec="http://www.springframework.org/schema/security"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context-2.5.xsd
                  http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
                  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
      default-lazy-init="true"&gt;
  
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan
          base-package="com.alt.survey.common.db.dao,com.alt.survey.common.db.service,com.alt.survey.common.db.dao,com.alt.survey.common.db.dao.impl,com.alt.survey.common.db.domain,com.alt.survey.common.db.service,com.alt.survey.common.db.service.impl" /&gt;
  
      &lt;!-- Aspect for auto logging --&gt;
      &lt;aop:aspectj-autoproxy /&gt;
      &lt;bean id="surveyAudit" class="com.alt.survey.common.SurveyLogging" /&gt;
      &lt;!-- Database configuration --&gt;
      &lt;bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="location"&gt;
              &lt;value&gt;file:C:\\Users\\vaibhav.kashyap\\Documents\\surveydbdetails\\db.properties&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;!-- log4j configuration --&gt;    
      &lt;bean id="log4jInitialization"
          class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;
          &lt;property name="targetClass" value="org.springframework.util.Log4jConfigurer" /&gt;
          &lt;property name="targetMethod" value="initLogging" /&gt;
          &lt;property name="arguments"&gt;
              &lt;list&gt;
                  &lt;value&gt;C:\\Users\\vaibhav.kashyap\\Documents\\surveydbdetails\\log4j.properties&lt;/value&gt;
                  &lt;value&gt;30000&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Using this configuration for  my entity manager through code which is also as follows :- </p>
  
  <pre><code> @PersistenceContext(unitName = "TalentPactFormEngine_New")
      protected EntityManager em;
  </code></pre>
  
  <p>which also failed.Now after trying every other solution i could find i have reached nowhere hence humbly requesting for help. Any sort of solution(new) will be highly appreciable.</p>