facebook

Hibernate org/hibernate/Session not found

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #246937 Reply

    ceronj
    Member

    When I try running the servlet below, I get the error below. The application complies correctly. When I run it outside of the servlet, in a dummy class with a main(), Hibernate works just fine. I used the MyEclipse Hibernate support so I assumed it added all the jar files correctly. I see the hibernate3.jar in the hibernate core in the classpath, so I don’t know what’s the problem. I even copied the jar into the WEB-INF/lib folder but that doesn’t work either.

    Please advise….

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: Error instantiating servlet class com.jsfdemo.ControllerServlet
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:595)

    root cause

    java.lang.NoClassDefFoundError: org/hibernate/Session
    java.lang.Class.getDeclaredConstructors0(Native Method)
    java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
    java.lang.Class.getConstructor0(Class.java:2640)
    java.lang.Class.newInstance0(Class.java:321)
    java.lang.Class.newInstance(Class.java:303)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:595)

    😡

    #246942 Reply

    ceronj
    Member

    Hello, anyone home? I really need a answer for this.

    #246946 Reply

    Haris Peco
    Member

    ceronj ,

    Class org/hibernate/Session is from hibernate3.jar.Do you add hibernate libraries in your projects ?

    #246953 Reply

    Riyad Kalla
    Member

    ceronj,
    In addition to what snpe suggested, please double check that your application server doesn’t already have hibernate JARs in it’s /lib directory that it might be picking up instead of yours.

    #246960 Reply

    ceronj
    Member

    Something’s not right here. I used the “add Hibernate capabilities” in MyEcllipse. When I did so, it added the Hibernate core and Hibernate advanced lib. This worked if I used Hibernate in a dummy class using main(), but not in a web environment—servlet. I added the hibernate3.jar to the WEB-INF/lib directory, but when I tried adding to the project, “properties->java build path->add jars” it would not show up. If I tinkered with the .classpath file, I’d get a build path error.

    I created a new project and did the following when using the add Hibernate capabilities:

    Selected both Hibernate 3.0 Core, and Hibernate 3.0 Advance

    Then selected: if check “copy checked lib jars to project folder and add to build-path,” copies to WEB-INF/lib

    (On the other project, I selected “if check “add checked lib to project build-path”

    Why didn’t this work in the first place? Why don’t the jars show up in Eclipse when I copied them into the WEB-INF/lib? How do I add them to my old project that still won’t work.

    #246962 Reply

    Haris Peco
    Member

    ceronj ,

    Please, use first case or try add libraries in project-Properties,MyEclipse-Web-deployment

    It doesn’t work for your second case, because you don’t add libraries in deployment

    best

    #246963 Reply

    Riyad Kalla
    Member

    Why didn’t this work in the first place? Why don’t the jars show up in Eclipse when I copied them into the WEB-INF/lib? How do I add them to my old project that still won’t work.

    You want to go to your Java Build Path > Libraries > Add Library.

    Also snpe is right, you need to navigate to your MyEclipse-Web > Deployment settings for your workbench or project and tell the deployment tool to deploy libraries on your build path, otherwise it ignores them and they stay put.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Hibernate org/hibernate/Session not found

You must be logged in to post in the forum log in