Announcement Announcement Module
Collapse
No announcement yet.
Resource: Add valid path not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resource: Add valid path not found

    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


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//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&#58;mysql&#58;//localhost&#58;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&#58;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 &#40;alternative to JTA&#41; -->
    	<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    
    	<!-- Transaction manager that delegates to JTA &#40;for a transactional JNDI DataSource&#41; -->
    	<!--
    	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
    	-->
    
    
    	<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
    
    	<!--
    	  - DMS's central data access object&#58; 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
    		- &#40;to suppress unnecessary flush attempts for read-only operations&#41;.
    		-
    		- 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>
    So what´s wrong?

  • #2
    So what´s wrong?
    Looks like an issue loading Pessoa.hbm.xml from the classloader. What version of Hibernate is it?

    Comment


    • #3
      Problem Solved

      Hi,

      the problem was caused by an incomplet hibernate.cfg.xml configuration.

      Code:
      <property name="configLocation">          
                 <value>META-INF/hibernate.cfg.xml</value>          
      </property>
      hibernate.cfg.xml

      <!-- DO NOT EDIT: This is a generated file that is synchronized -->
      <!-- by MyEclipse Hibernate tool integration. -->
      <hibernate-configuration>

      <session-factory>
      <!-- properties -->
      <property name="connection.username">root</property>
      <property name="dialect">net.sf.hibernate.dialect.MySQLDiale ct</property>
      <property name="jndi.url">java:/dmsDS</property>
      <property name="jndi.class"></property>
      <property name="connection.datasource">dmsDS</property>
      <property name="connection.password"></property>

      <!-- mapping files -->
      <!-- The following mapping element was auto-generated in -->
      <!-- order for this file to conform to the Hibernate DTD -->
      <mapping resource="Add valid path"/>
      </session-factory>

      </hibernate-configuration>
      The solution was just to add a hbm.xml valid path :-)

      thanks for help.

      bye.

      Comment


      • #4
        That makes sense. Was looking at the hibernate source which has:
        Code:
        throw new MappingException&#40;"Resource&#58; " + path + " not found"&#41;;

        Comment

        Working...
        X