Results 1 to 9 of 9
  1. #1
    balaji shan is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Unhappy ClassnotFoundException

    Hi All,

    I am trying to create a JPG using Jfreechart. I have written a code which runs perfectly as expected when i run the code as a Standalone Program. But when i try to access the same code using a Servlet, i m getting a ClassNotFoundException and a NoclassDefFound error. I tried various sources over the net to solve this issue. but No Hope !! :( Can somebody help me here ? am i missing out something ?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Without at the least the full exception we can't say what your problem is other than you have classes missing.

  3. #3
    balaji shan is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    Thanks for replying at the soonest.. :) PFB the error msg

    javax.servlet.ServletException: Servlet execution threw an exception


    root cause

    java.lang.NoClassDefFoundError: org/jfree/data/time/RegularTimePeriod
    selectEG.doPost(selectEG.java:51)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:729)


    root cause

    java.lang.ClassNotFoundException: org.jfree.data.time.RegularTimePeriod
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1438)
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1284)
    selectEG.doPost(selectEG.java:51)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:729)

    I am using a subclass of the RegularTimePeriod class(minute.class,hour.class).

    The Exact scenario here is that i am creating a Time series chart with the datas from a file. so when it works as a standalone program everything is fine. but when i call the code via a servlet, i am getting the above mentioned error :( please help..

    The necessary header files have all been imported for this.
    Last edited by balaji shan; 01-19-2011 at 02:57 PM. Reason: more comment added

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Have you deployed the jar containing that class in your webapp?

  5. #5
    balaji shan is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    Yes, I have put those Jar files in the Webcontent of My project. I am using Eclipse IDE. I have also set the buildpaths correctly. But still no luck !! :(

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    So that jar is in WEB-INF/lib?

  7. #7
    balaji shan is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    yeah.. this solved it.. Thanks a ton :) I would Appreciate it if you can please explain me why this happened ? Initially i was running the code as a stand alone program where things worked fine.(I dint import the Jar Files, but i had configured the buildpath correctly). But later i faced this problem.. an after deploying the jar files in the web-inf/lib its working fine. i cant understand why

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    By standalone are you talking about running it through Eclipse (for example)? Rather than via a Servlet on Tomcat?

    In which case Eclipse (or whatever IDE) will handle your classpath, generally sticking any jars it uses to compile the code into the runtime classpath.

    Tomcat, on the other hand, launches each webapp as a separate thing, with its own classpath. That classpath consists of the WEB-INF/classes directory (where your code sits) and all jars inside the WEB-INF/lib directory. So simply sticking your dependent jar in there means Tomcat will pick it up when it runs your webapp.

    Of course, Eclipse (or whatever IDE) should create your webapp with all this in it, but exactly where that option is I can't remember. It's probably down to how it packages your app.

  9. #9
    balaji shan is offline Member
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    Thanks a lot for the info.

    yeah, By standalone i meant a single program run in Eclipse. (just like a Hello world! program :) )

Similar Threads

  1. ClassNotFoundException
    By meprasobh in forum New To Java
    Replies: 2
    Last Post: 10-17-2010, 03:32 PM
  2. classNotFoundException
    By jyothi.priyanka in forum NetBeans
    Replies: 5
    Last Post: 08-24-2010, 10:13 AM
  3. ClassNotFoundException
    By oontvoo in forum Java Applets
    Replies: 7
    Last Post: 05-13-2010, 11:09 PM
  4. ClassNotFoundException
    By lgpublic in forum Advanced Java
    Replies: 5
    Last Post: 04-23-2010, 03:05 PM
  5. ClassNotFoundException
    By Edward in forum New To Java
    Replies: 2
    Last Post: 06-29-2009, 07:08 PM

Tags for this Thread

Posting Permissions

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