• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to solve NoClassDefFoundError while creating XmlBeanFactory object in springs?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check the jar file list neeeded to run this spring example?
 
sridhar bvap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try placing the jar files in tomcat\common\lib instead of tomcat\server\lib ,
 
No, tomorrow we rule the world! With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic