"org.hibernate.Session" ClassNotFoundException
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: "org.hibernate.Session" ClassNotFoundException

  1. #1
    Join Date
    May 2009
    Posts
    13

    Resolved [SOLVED] "org.hibernate.Session" ClassNotFoundException

    Hello to all,

    Despite I added all necessary .jar files to project, I always take boring exception warnings that say "class not found". I added the code and exception output below. I'll be so happy if someone can help me.

    Thanx in advance..
    With regards,
    T
    -----------------------------------------------------
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    KisiHelper kh = new KisiHelper(); // ======> *Exception Warning!!!*
    try {
    JSONArray arr = kh.getAll();
    response.getWriter().write(arr.toString());
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    ---------------------------------------------------------
    public class KisiHelper {

    public JSONArray getAll() {
    JSONArray arr = null;

    try {
    System.out.println("KisiHelper calisti..");
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction transaction = session.beginTransaction();
    String hql = "from Kisi";
    Query query = session.createQuery(hql);
    List<Kisi> list = query.list();
    List<Kisi> kisiList = list;
    arr = JSONArray.fromObject(kisiList);
    transaction.commit();
    session.close();
    } catch(Exception e) {
    e.printStackTrace();
    }
    return arr;
    }
    }
    ----------------------------------------------------------------
    *Exception:*

    java.lang.ClassNotFoundException: org.hibernate.Session
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    * at servlets.tabloDoldur.doGet(tabloDoldur.java:34)*
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)
    Last edited by talha06; February 28th, 2010 at 12:18 PM. Reason: Solved..

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: "org.hibernate.Session" ClassNotFoundException

    I added all necessary .jar files to project
    If that was true, you wouldn't get that error...

    You need the Hibernate jar on your classpath (e.g. hibernate3.jar or hibernate-3xxx.jar).

    Doing more things faster is no substitute for doing the right things...
    S. R. Covey
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    May 2009
    Posts
    13

    Re: "org.hibernate.Session" ClassNotFoundException

    Quote Originally Posted by dlorde View Post
    If that was true, you wouldn't get that error...

    You need the Hibernate jar on your classpath (e.g. hibernate3.jar or hibernate-3xxx.jar).

    Doing more things faster is no substitute for doing the right things...
    S. R. Covey
    Here's the link for my small test project. I'll be happy if you can try it on your computer.
    Thanks in advance..
    ~~EDIT~~
    Last edited by talha06; February 28th, 2010 at 12:17 PM.

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: "org.hibernate.Session" ClassNotFoundException

    No thanks.

    Did adding the hibernate jar to your classpath work?

    The value of a prototype is in the education it gives you, not in the code itself...
    A. Cooper
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  5. #5
    Join Date
    May 2009
    Posts
    13

    Exclamation Re: "org.hibernate.Session" ClassNotFoundException

    Quote Originally Posted by dlorde View Post
    No thanks.

    Did adding the hibernate jar to your classpath work?

    The value of a prototype is in the education it gives you, not in the code itself...
    A. Cooper
    I just added all my external jar files into my server's (Apache Tomcat 6.0) "lib" folder. Eventually, this exception has gone.. But unfortunately now I take another exception: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException" I googled this expection and I added commons-lang-2.5.jar into my lib. Despite that it still gives exception..

  6. #6
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: "org.hibernate.Session" ClassNotFoundException

    I can only repeat that if the correct jar is on the classpath, you won't get the exception. Are you certain a jar containing the relevant class is on the server classpath (e.g. WEB-INF/lib/)?

    Who dares to teach must never cease to learn...
    J.C. Dana
    Last edited by dlorde; February 28th, 2010 at 11:29 AM.
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  7. #7
    Join Date
    May 2009
    Posts
    13

    Re: "org.hibernate.Session" ClassNotFoundException

    Quote Originally Posted by dlorde View Post
    I can only repeat that if the correct jar is on the classpath, you won't get the exception. Are you certain a jar containing the relevant class is on the server classpath (e.g. WEB-INF/lib/)?

    Who dares to teach must never cease to learn...
    J.C. Dana
    OK thank you so much dlorde.. I appreciated from your help..
    With regards,
    Talha

  8. #8
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: "org.hibernate.Session" ClassNotFoundException

    Was it something I said (repeated) ?

    If Java had true garbage collection, most programs would delete themselves upon execution...
    Robert Sewell
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  9. #9
    Join Date
    May 2009
    Posts
    13

    Resolved Re: "org.hibernate.Session" ClassNotFoundException

    Quote Originally Posted by dlorde View Post
    Was it something I said (repeated) ?

    If Java had true garbage collection, most programs would delete themselves upon execution...
    Robert Sewell
    yes, exactly. It was occured because of 'build path' mistake..
    Thanks you so much again.

  10. #10
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: "org.hibernate.Session" ClassNotFoundException

    Wish I'd mentioned it...

    I donít care if it works on your machine! We are not shipping your machine!
    Vidiu Platon
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center