Hello peaple!!
I'm trying to run some unit tests with JUnit but I´m getting some errors messages.
Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'manterPessoa' defined in class path resource [META-INF/applicationContext.xml]: Can't resolve reference to bean 'pessoaDao' while setting property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pessoaDao' defined in class path resource [META-INF/applicationContext-hibernate.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Resource: Add valid path not found org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pessoaDao' defined in class path resource [META-INF/applicationContext-hibernate.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Resource: Add valid path not found org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Resource: Add valid path not found net.sf.hibernate.MappingException: Resource: Add valid path not found at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:334) at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018) at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974) at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:917) at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:424) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1075) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:349) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:257) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:982) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:905) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:846) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:675) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:331) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:257) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:982) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:905) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:846) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:675) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:331) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:257) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146) at br.syndeo.dms.services.teste.pessoa.ManterPessoaTest.setUp(ManterPessoaTest.java:19) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
This is my applicationContext-hibernate.xml
So what´s wrong?Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for DMS on Hibernate. --> <beans> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <!-- Local DataSource that works in any environment. Just use for testes--> <!-- Note that DriverManagerDataSource does not pool; it is not intended for production --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="url"><value>jdbc:mysql://localhost:3306/dms</value></property> <property name="username"><value>root</value></property> <property name="password"><value></value></property> </bean> <!-- JNDI DataSource for J2EE environments --> <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>java:dmsDS</value></property> </bean> --> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="dataSource"/></property> <property name="mappingResources"> <list> <value>br/syndeo/dms/domain/pessoa/Pessoa.hbm.xml</value> </list> </property> <property name="configLocation"> <value>META-INF/hibernate.cfg.xml</value> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) --> <!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> --> <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --> <!-- - DMS's central data access object: Hibernate implementation. --> <bean id="pessoaDao" name="pessoaDao" class="br.syndeo.dms.persistence.hibernate.pessoa.PessoaDaoHibernateImpl"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <bean id="clienteDao" name="clienteDao" class="br.syndeo.dms.persistence.hibernate.pessoa.ClienteDaoHibernateImpl"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <!-- - Transactional proxy for Petclinic's central data access object. - - Defines specific transaction attributes with "readOnly" markers, - which is an optimization that is particularly valuable with Hibernate - (to suppress unnecessary flush attempts for read-only operations). - - Note that in a real-life app with multiple transaction proxies, - you will probably want to use parent and child bean definitions - as described in the manual, to reduce duplication. --> <!-- <bean id="clinic" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="transactionManager"/></property> <property name="target"><ref local="clinicTarget"/></property> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="store*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> --> </beans>


Reply With Quote