Results 1 to 3 of 3
  1. #1
    chandrupsekar is offline Member
    Join Date
    Dec 2010
    Posts
    7
    Rep Power
    0

    Default 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

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default 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.

    Java Code:
    java -cp . HelloClient
    The dot (".") symbol add your current working directory to the classpath.

  3. #3
    chandrupsekar is offline Member
    Join Date
    Dec 2010
    Posts
    7
    Rep Power
    0

    Default 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

  1. NoClassDefFoundError
    By sriram56 in forum IntelliJ IDEA
    Replies: 0
    Last Post: 11-26-2011, 03:04 AM
  2. Replies: 1
    Last Post: 12-27-2010, 05:21 PM
  3. NoClassDefFoundError
    By Josisco in forum JDBC
    Replies: 2
    Last Post: 10-30-2010, 08:07 PM
  4. Replies: 0
    Last Post: 04-02-2008, 10:36 AM
  5. Replies: 0
    Last Post: 10-04-2007, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •