jg.guerra
Jun 30th, 2005, 07:44 AM
Hi everybody !!
I have a Hibernete 3.0.5-Spring 1.2.1 simple test case with the following stack trace:
org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'carDao' is defined: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [beanRefFactory]; root of BeanFactory hierarchy
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:351)
at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedBeanDefinition(AbstractBeanFa ctory.java:640)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:151)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:540)
at CarDaoTest.setUp(CarDaoTest.java:42)
at junit.framework.TestCase.runBare(TestCase.java:125 )
at junit.framework.TestResult$1.protect(TestResult.ja va: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:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
The refered Java code with the error is:
....
private ApplicationContext ctx = new ClassPathXmlApplicationContext("beanRefFactory.xml");
......
protected void setUp() throws Exception {
super.setUp();
carDAO = (CarDao)ctx.getBean("carDao");
}
....
the content of the applicationContext.xml file
<beans>
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<!-- applicationContext merge-point -->
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFac toryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>/Car.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.query_cache_factory">org.hibernate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
<!-- The Hibernate interceptor -->
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterc eptor">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<!-- Car Entity Implementation -->
<bean id="carDaoTarget" class="CarDaoImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- Car Entity Proxy -->
<bean id="carDao" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target"><ref bean="carDaoTarget"/></property>
<property name="proxyInterfaces">
<value>CarDao</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
</list>
</property>
</bean>
</beans>
The content of the beanRefFactory.xml file is:
<beans>
<bean id="beanRefFactory"
class="org.springframework.context.support.ClassPathXmlAp plicationContext">
<constructor-arg>
<list>
<value>applicationContext.xml</value>
<value>applicationContext-dataSource.xml</value>
<!-- beanRefFactory merge-point -->
</list>
</constructor-arg>
</bean>
</beans>
Please drop me a few words if anybody has any coments about this error !
Thanks !!
I have a Hibernete 3.0.5-Spring 1.2.1 simple test case with the following stack trace:
org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'carDao' is defined: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [beanRefFactory]; root of BeanFactory hierarchy
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:351)
at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedBeanDefinition(AbstractBeanFa ctory.java:640)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:151)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:540)
at CarDaoTest.setUp(CarDaoTest.java:42)
at junit.framework.TestCase.runBare(TestCase.java:125 )
at junit.framework.TestResult$1.protect(TestResult.ja va: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:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
The refered Java code with the error is:
....
private ApplicationContext ctx = new ClassPathXmlApplicationContext("beanRefFactory.xml");
......
protected void setUp() throws Exception {
super.setUp();
carDAO = (CarDao)ctx.getBean("carDao");
}
....
the content of the applicationContext.xml file
<beans>
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<!-- applicationContext merge-point -->
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFac toryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>/Car.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.query_cache_factory">org.hibernate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
<!-- The Hibernate interceptor -->
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterc eptor">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<!-- Car Entity Implementation -->
<bean id="carDaoTarget" class="CarDaoImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- Car Entity Proxy -->
<bean id="carDao" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target"><ref bean="carDaoTarget"/></property>
<property name="proxyInterfaces">
<value>CarDao</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
</list>
</property>
</bean>
</beans>
The content of the beanRefFactory.xml file is:
<beans>
<bean id="beanRefFactory"
class="org.springframework.context.support.ClassPathXmlAp plicationContext">
<constructor-arg>
<list>
<value>applicationContext.xml</value>
<value>applicationContext-dataSource.xml</value>
<!-- beanRefFactory merge-point -->
</list>
</constructor-arg>
</bean>
</beans>
Please drop me a few words if anybody has any coments about this error !
Thanks !!