Hi Friends
When I am writing following code in Eclipse the XMLBeanFactory class show in strike and it also says javadoc not available. I include all jar files required for XmlBeanFactory like
"spring-beans-2.5.6.jar". But problem is still same it produce following exception
-------------------------
Error/Exception
Exception in
thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:83)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.<init>(FactoryBeanRegistrySupport.java:43)
at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:176)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:155)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:166)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:156)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:77)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:66)
at net.roseindia.TestRunSpring.main(TestRunSpring.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
--------------------------
Three files code here and I am running TestRunSpring.java as application
Code 1 is here TestRunSpring.java
package net.roseindia;
import java.util.Map;
import org.springframework.beans.factory.xml.
XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.Assert;
@SuppressWarnings("deprecation")
public class TestRunSpring {
/**
* @param args
*/
@SuppressWarnings("deprecation")
public static void main(
String[] args) {
// TODO Auto-generated method stub
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
"SpringHelloWorld.xml"));
TestSpring1 myBean = (TestSpring1) beanFactory
.getBean("Spring3HelloWorldBean");
myBean.sayHello();
}
}
code 2 is here TestSpring1.java
package net.roseindia;
public class TestSpring1 {
/**
* @param args
*/
public void sayHello(){
System.out.println("Hello Spring 3.0");
}
}
code 3 TestSpringHello.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="TestSpring1"
class="net.roseindia.TestSpring1" />
</beans>
Please help