It's not a secret anymore!*
The moose likes Other Application Frameworks and the fly likes how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs?" Watch "how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs?" New topic
Author

how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs?

sridhar bvap
Greenhorn

Joined: Mar 12, 2008
Posts: 19
Hi to all,
Iam trying to run simple spring application manually. While running the helloclient program it is throwing the NoClassDefFoundError.
iam providing the code.
public interface hello
{
public String sayhello(String a);
}

...
public class helloimpl implements hello
{
private String greeting;public helloimpl(){}public helloimpl(String a){ greeting=a; }
public String sayhello(String s){ return greeting+s; }
public void setGreeting(String a){ greeting=a; }

}
...
import java.io.*;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.xml.*;
import org.springframework.core.io.*;
public class helloclient
{
public static void main(String args[]) throws Exception{
try{
System.out.println("Please wait...");
Resource rs = new ClassPathResource("hello.xml");
BeanFactory factory = new XmlBeanFactory(rs);
hello bean1 = (hello)factory.getBean("hello");
String s = bean1.sayhello(args[0]);
System.out.println("The value is "+s);
}catch(Exception e){
System.out.println("The Exception is ####"+e);
}
}
}
...
iam setting classpath to the spring.jar and commons-logging.jar of tomcat41\server\lib to the current working directory.

iam using spring 1.2.9.
iam getting the following error while running application

E:\Spring\springdemo>java helloclient "sridhar"
Please wait...
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lo
gging/LogFactory
at org.springframework.util.ClassUtils.<clinit>(ClassUtils.java:59)
at org.springframework.core.io.ClassPathResource.<init>(ClassPathResourc
e.java:82)
at org.springframework.core.io.ClassPathResource.<init>(ClassPathResourc
e.java:64)
at helloclient.main(helloclient.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFacto
ry
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 4 more

iam running program in windowsXP.

if any buddy know please help me.


thank you one and all.

[ May 21, 2008: Message edited by: sridhar bvap ]

[ May 21, 2008: Message edited by: sridhar bvap ]
[ May 21, 2008: Message edited by: sridhar bvap ]
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Did you check the jar file list neeeded to run this spring example?
sridhar bvap
Greenhorn

Joined: Mar 12, 2008
Posts: 19
iam using spring.jar of 1.2.9 version and commons-logging-1.1.1.jar of apache tomcat 4 for running above application....Does it require more....?
kiran sharma
Greenhorn

Joined: May 30, 2008
Posts: 1
try placing the jar files in tomcat\common\lib instead of tomcat\server\lib ,
 
 
subject: how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs?