-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem while saving an object
PostPosted: Sat Dec 04, 2010 2:39 pm 
Newbie

Joined: Sat Dec 04, 2010 2:28 pm
Posts: 3
HI , i newbie to Hibernate just started learning Hibernate .

I am trying to design simple JSP page(online book application) in which a user will fill field like book name ,book cost, prize n author n all
after filling form it submit and all filled data is to be store in book schema .if i running java file alone the values get store in database , but when i taking this values from jsp and try to save it there it is giving me error .


exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/hibernate/Session
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/hibernate/Session
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.view.addNewBook_jsp._jspService(addNewBook_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


My Javafile is like
package impjava;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class TestOperation {
private Session session = null;

public void AddBook(String bkname,String auth,String pub,float prize)
{
Session session = null;
try{
SessionFactory fact= new Configuration().configure().buildSessionFactory();
session = fact.openSession();
Transaction tx = session.beginTransaction();
tx.begin();
Books bk = new Books();
bk.setBookname(bkname);
bk.setAuther(auth);
bk.setPrize(prize);
bk.setPublisher(pub);
session.save(bk);
tx.commit();

}
catch(Exception E)
{
E.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub

TestOperation tst = new TestOperation() ;
tst.AddBook("kkkkk","dssdsd","ssasas",108f);
/*Session session = null;
try{
SessionFactory fact= new Configuration().configure().buildSessionFactory();
session = fact.openSession();
Transaction tx = session.beginTransaction();
tx.begin();
Books bk = new Books();
bk.setBookname("Hibanate Tutorial");
bk.setAuther("Mark Zuckrburg");
bk.setPrize(100f);
bk.setPublisher("Tata McGraw");
session.save(bk);
tx.commit();

}
catch(Exception E)
{
E.printStackTrace();
}*/
}

}

and JSP file from where i am calling addBook method is as follows
<%@ page import ="impjava.*" %>
<html>
<head><title>Added New Book</title></head>
<body>

<%
TestOperation tst = new TestOperation();
String bkname = request.getParameter("bname");
String pub = request.getParameter("pub");
float prize = Float.parseFloat(request.getParameter("prize"));
String auth = request.getParameter("auth");
//tst.AddBook(bkname,auth,pub,prize);
%>

</body>
</html>


Top
 Profile  
 
 Post subject: Re: Problem while saving an object
PostPosted: Sat Dec 04, 2010 6:32 pm 
Beginner
Beginner

Joined: Tue Nov 02, 2010 4:29 am
Posts: 21
The correct hibernate jar file is not in your servlet container's class path, e.g. WEB-INF/lib.
To find which jar file use a jar finding service like:

http://www.jarfinder.com/

Here are some results that look like they might help:

http://www.jarfinder.com/index.php/java ... te.Session


Top
 Profile  
 
 Post subject: Re: Problem while saving an object
PostPosted: Sun Dec 05, 2010 1:02 am 
Newbie

Joined: Sat Dec 04, 2010 2:28 pm
Posts: 3
Hey that's Work thax a lot [:)]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.