1. Error description
2016-03-05 11:19:53 WARN [Org.springframework.web.context.support.XmlWebApplicationContext] Exception encountered During context initialization-cancelling Refresh Attemptorg.springframework.beans.factory.BeanCreationException: Error creating Bean with Name ' sessionfactory ' defined in class path resource [Applicationcontext.xml]: Cannot resolve ref erence to Beans ' dataSource ' while the setting bean property ' DataSource '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' t resolve reference-bean ' dataSource ' in P Arent Factory:no Parent Factory availableat Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:336) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:108) at ORG.SPRINGFRAMEWORK.BEANS.FACTORY.SUPPORT.ABstractautowirecapablebeanfactory.applypropertyvalues (abstractautowirecapablebeanfactory.java:1471) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1216) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:538) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:229) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:193) at Org.springframework.beans.factory.support.DefaultLiStablebeanfactory.preinstantiatesingletons (defaultlistablebeanfactory.java:706) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:757) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:480) at Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (contextloader.java:403) At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:5068) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5584) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:147) at org.apache.catalina.core.containerbase$ Startchild.call (containerbase.java:1572) at Org.apache.catalina.core.ContainerBAse$startchild.call (containerbase.java:1562) at Java.util.concurrent.FutureTask.run (futuretask.java:262) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Java.lang.Thread.run ( thread.java:745) caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' t resolve reference-bean ' dataSource ' in P Arent Factory:no Parent Factory availableat Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:321) ... more2016-03-05 11:19:53 ERROR [Org.springframework.web.context.ContextLoader] Context initialization Failedorg.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined In class path resource [Applicationcontext.xml]: Cannot resolve reference toBean ' dataSource ' while setting beans property ' DataSource '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' t resolve reference-bean ' dataSource ' in P Arent Factory:no Parent Factory availableat Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:336) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:108) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues ( abstractautowirecapablebeanfactory.java:1471) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1216) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( Abstractautowirecapablebeanfactory.java:538) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:229) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:193) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:706) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:757) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:480) at Org.springframework.web.context.ConTextloader.configureandrefreshwebapplicationcontext (contextloader.java:403) at Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:5068) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5584) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:147) at org.apache.catalina.core.containerbase$ Startchild.call (containerbase.java:1572) at Org.apache.catalina.core.containerbase$startchild.call ( containerbase.java:1562) at Java.util.concurrent.FutureTask.run (futuretask.java:262) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Java.lang.Thread.run ( thread.java:745) caused by:org.springframework.beans.factory.BeanCreatIonexception:error creating Bean with Name ' sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' T resolve reference to beans ' dataSource ' in parent Factory:no parent Factory Availableat Org.springframework.beans.factor Y.support.beandefinitionvalueresolver.resolvereference (beandefinitionvalueresolver.java:321) ... March 05, 2016 11:19:53 am org.apache.catalina.core.StandardContext listenerstart Serious: Exception Sending context Initia Lized event to listener instance of class Org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating Bean with Name ' sessionfactory ' defined in class path resource [Applicationcontext.xml]: Cannot resolve ref erence to Beans ' dataSource ' while the setting bean property ' DataSource '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' t resolveReference to Beans ' dataSource ' in parent Factory:no parent Factory Availableat Org.springframework.beans.factory.support . Beandefinitionvalueresolver.resolvereference (beandefinitionvalueresolver.java:336) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:108) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues ( abstractautowirecapablebeanfactory.java:1471) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1216) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:538) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) AT Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:229) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:193) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:706) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:757) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:480) at Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (contextloader.java:403) At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (Contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:5068) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5584) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:147) at org.apache.catalina.core.containerbase$ Startchild.call (containerbase.java:1572) at Org.apache.catalina.core.containerbase$startchild.call ( containerbase.java:1562) at Java.util.concurrent.FutureTask.run (futuretask.java:262) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Java.lang.Thread.run ( thread.java:745) caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Sessionfactory ' defined in class path resource [Applicationcontext.xml]: Can ' t resolve reference-bean ' dataSource ' in P Arent Factory:no Parent Factory availableat org.springframework.beans.factory.support.bEandefinitionvalueresolver.resolvereference (beandefinitionvalueresolver.java:321) ... More
2. Cause of Error
<bean id= "sessionfactory" class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean" > <property name= "DataSource" > <ref parent= "DataSource"/> </property> </bean >
<ref/> with the Parent property, the correct configuration is <ref bean= "DataSource"/>
3. Solutions
<bean id= "sessionfactory" class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean" > <property name= "DataSource" > <ref bean= "DataSource"/> </property> </bean >
Can ' t resolve reference to beans ' dataSource ' in parent Factory:no parent factory available