AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PLEASE HELP! Tomcat and Hibernate ServletException, net/sf/

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Tung Chau
Guest





PostPosted: Fri Aug 20, 2004 4:19 am    Post subject: PLEASE HELP! Tomcat and Hibernate ServletException, net/sf/ Reply with quote



Hi,
I am newbie to Hibernate. I followed the instructions on the following
page to configure Tomcat to work with Hibernate.
http://www.hibernate.org/hib_docs/reference/en/html/quickstart.html
I tested hibernate with a simple Employee table and Employee.hbm.xml
===================================================================
My /src directory has
hibernate.cfg.xml at the root.
HibernateUtil.java inside package proj.db.
Employee.java inside package proj.mapping.
Employee.hbm.xml inside package proj.mapping.
==================================================================
The following code is put in test.jsp to test hibernate
"try{
Session s = HibernateUtil.currentSession();

Transaction tx= s.beginTransaction();

Employee E = new Employee();
E.setFirstName("blue");
E.setLastName("blue");
E.setEmail("blue (AT) gmail (DOT) com");

s.save(E);
tx.commit();

HibernateUtil.closeSession();
}catch (Exception e) {
out.println(e.getMessage());
}"
================================================
package proj.db;

import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;

public class HibernateUtil {

//private static Log log = LogFactory.getLog(HibernateUtil.class);

private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory
Configuration conf= new Configuration()
.addClass(elearning.mapping.Employee.class);
//sessionFactory = new
Configuration().configure().buildSessionFactory();
sessionFactory = conf.buildSessionFactory();
} catch (Throwable ex) {
System.out.println("HUHUHU");
System.out.println("******" + ex.getMessage());
//log.error("Initial SessionFactory creation failed.",
ex);
throw new ExceptionInInitializerError(ex);
}
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}
================================================================
========================================================
I got the following Servlet Exception
type Exception report

message

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

exception

org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

.............
root cause

javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:106)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

=======================================================
Here is part of the output in catalina.out:
"Aug 19, 2004 8:43:16 PM
net.sf.hibernate.transaction.TransactionManagerLookupFactory
getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use
of process level read-write cache is not recommended)
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.SettingsFactory
buildSettings
INFO: Use scrollable result sets: true
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.SettingsFactory
buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.SettingsFactory
buildSettings
INFO: Optimize cache for minimal puts: false
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.SettingsFactory
buildSettings
INFO: Query language substitutions: {}
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.SettingsFactory
buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
Aug 19, 2004 8:43:16 PM net.sf.hibernate.cfg.Configuration
configureCaches
INFO: instantiating and configuring caches
HUHUHU
******net/sf/cglib/core/KeyFactory


Stopping service Tomcat-Standalone
Aug 19, 2004 8:43:03 PM org.apache.coyote.http11.Http11Protocol
destroy
INFO: Stoping http11 protocol on 8080
Catalina:type=ThreadPool,name=http8080"
==============================================================
I don't know what was going on.
What does the "net/sf/cglib/core/KeyFactory" message printed out above
mean?
Is there anything wrong with my configuration?
Thanks. I would appreciate any help.
Tung Chau
Back to top
Murray
Guest





PostPosted: Fri Aug 20, 2004 6:42 am    Post subject: Re: PLEASE HELP! Tomcat and Hibernate ServletException, net Reply with quote




"Tung Chau" <tungchau81 (AT) yahoo (DOT) com> wrote


Quote:
I don't know what was going on.
What does the "net/sf/cglib/core/KeyFactory" message printed out above
mean?
Is there anything wrong with my configuration?
Thanks. I would appreciate any help.
Tung Chau

It might be more useful to print out the entire stack trace instead of just
getMessage(). Quite often messages are useless on their own...

See Exception#printStackTrace()



Back to top
Tung Chau
Guest





PostPosted: Fri Aug 20, 2004 7:33 pm    Post subject: Re: PLEASE HELP! Tomcat and Hibernate ServletException, net Reply with quote



"Murray" <parps (AT) SMAFFoffSPAMMER (DOT) optusnet.SPAMMAGE.com.au> wrote

Quote:
"Tung Chau" <tungchau81 (AT) yahoo (DOT) com> wrote in message
news:2580601f.0408192019.870eb34 (AT) posting (DOT) google.com...

I don't know what was going on.
What does the "net/sf/cglib/core/KeyFactory" message printed out above
mean?
Is there anything wrong with my configuration?
Thanks. I would appreciate any help.
Tung Chau

It might be more useful to print out the entire stack trace instead of just
getMessage(). Quite often messages are useless on their own...

See Exception#printStackTrace()

===========================================================
Oh, thanks for the tip. I forgot about that. Here is the the error I
got:
HUHUHU
******net/sf/cglib/core/KeyFactory
java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.
java:236)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.
java:791)
at elearning.db.HibernateUtil.<clinit>(HibernateUtil.java:1Cool
at org.apache.jsp.test_jsp._jspService(test_jsp.java:77)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
..java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
95)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
===============================================================
Has anybody had the same NoClassDefFound error? I just had
hibernate2.jar in my /lib directory

Back to top
Christophe Vanfleteren
Guest





PostPosted: Fri Aug 20, 2004 7:41 pm    Post subject: Re: PLEASE HELP! Tomcat and Hibernate ServletException, net Reply with quote

Tung Chau wrote:

Quote:
Oh, thanks for the tip. I forgot about that. Here is the the error I
got:
HUHUHU
******net/sf/cglib/core/KeyFactory
java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
at

net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.
java:236)
at
snip part of stacktrace/
===============================================================
Has anybody had the same NoClassDefFound error? I just had
hibernate2.jar in my /lib directory

You also need to add the hibernate dependencies to your classpath (/lib
directory). Starting with cglib. I'm pretty sure that hibernate also has
other dependencies, and that this is documented in the documentation that
comes with it.

--
Kind regards,
Christophe Vanfleteren

Back to top
Tung Chau
Guest





PostPosted: Fri Aug 20, 2004 9:38 pm    Post subject: Re: PLEASE HELP! Tomcat and Hibernate ServletException, net Reply with quote

I found the solution for the above problem already.
It was because I didn't add some third party jar files in the class
path, for examples, odmg.jar ...
Tung Chau
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.