-
Mar 30th, 2011, 08:10 PM
#1
I can not get a bean from the Spring 2.5
if you have condition to answer me, please do this.
I can not read any bean from spring 2.5.
I already have read magazines and articles on internet but I never have
success. Can you help me.
// I am using the IDE Eclipse Helios with JSF 2.0, TomCat 7.0, Hibernate 3.0 and Spring 2.5, but I think the problem is related to Spring.
//Creating the applicationContext: (This part works very well)
springContext = new ClassPathXmlApplicationContext("classpath*:src/config/applicationContext.xml");
//Trying to create the object named myObject from Spring 2.5.
//I could not read the bean from Spring.
//The error says the myObject is not defined. But the myObject is.
ClassTest myObject =(ClassTest) getSpringContext().getBean("myObject");
//Configuration file: applicationContext.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schem...-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
<!-- It is very important to say that the path and class are corrects and both exist.-->
<beans:bean id="myObject" class="src.test.ClassTest" ></beans:bean>
</beans:beans>
//Error shown from running on the JUnit Test.
org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'myObject' is defined
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:387)
at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:96
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:246 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:881)
at config.SpringAccess.getClassTest(SpringAccess.java :42)
Thank you in advance,
Régis de O. Santos(from BRAZIL)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules