Results 1 to 3 of 3
- 04-26-2012, 02:14 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
NoClassDefFoundError while I run my first Spring program
Hi All,
I was trying to run a program using Eclipse 3.5 using File->New->Spring Project.
I coded all the necessary files. What I did was set the class path using MyComputer -> (Right Click) -> Environment Variables -> Add User Variable -> Classpath.
CLASSPATH=C:\<spring location>\dist\spring.jar
First I compiled all the java files in a cmd prompt, it compiled successfully but while running i.e java HelloClient it gave me the NoClassDefFoundError
Prior to this I tried the same using eclipse after creating interfaces, java files, xml files (as mentioned in a tutorial) but I got the error NoClassDefFoundError
I added all the .jar files and reconfigured all the settings but am getting this error.
Could any of you (who have encoutered the same prob in Eclipse) give a glimpse or tips in setting and configuring for avoiding this error : NoClassDefFoundError
- 04-26-2012, 02:47 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: NoClassDefFoundError while I run my first Spring program
Basically the java command cannot find your HelloClient class in the classpath. Try adding the current path where you HelloClient.class is using the -cp argument when running the java command.
The dot (".") symbol add your current working directory to the classpath.Java Code:java -cp . HelloClient
Website: Learn Java by Examples
- 04-27-2012, 01:35 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 7
- Rep Power
- 0
Re: NoClassDefFoundError while I run my first Spring program
I got it resolved my friend, what you say might be correct. But when I added few missing jars (common-logging.jar) the exception was cleared.
Now I face a different problem. I had a xml file in the same location and also to the output folder but when I compile I get this exception:
org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from class path resource [hello.xml]; nested exception is java.io.FileNotFoundException: class path resource [hello.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loloadBeanDefinitions(XmlBeanDefinitio nReader.java:302)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:78)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:66)
at com.myspring.HelloClient.main(HelloClient.java:19)
Caused by: java.io.FileNotFoundException: class path resource [hello.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getI nputStream(ClassPathResource.java:158)
Similar Threads
-
NoClassDefFoundError
By sriram56 in forum IntelliJ IDEAReplies: 0Last Post: 11-26-2011, 03:04 AM -
possible overlapping jars in spring annotated mvc/spring security project
By savantics in forum Web FrameworksReplies: 1Last Post: 12-27-2010, 05:21 PM -
NoClassDefFoundError
By Josisco in forum JDBCReplies: 2Last Post: 10-30-2010, 08:07 PM -
How to run Client program in Swing/AWT using Spring Framework
By Java Tip in forum Spring FrameworkReplies: 0Last Post: 04-02-2008, 10:36 AM -
How to run Client program in Swing/AWT using Spring Framework
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks