-->
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: Is TOMCAT 5.5.x tested / supported? What should I use?
PostPosted: Tue Feb 21, 2006 1:12 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
I am using the latest version of everything I can find and still have the same problem. Everytime tomcat reloads my hibernate test app it gobbles up memory and latter produces out of memory errors.

I am just using hibernate with its assoicated libary. I have a listner configured that starts the sesssionFactory (see below). And I reload using the tomcat manager.

It seems that tomcat out of the box with hibernate out of the box doesn't work together, is that right?

I see this thread here
http://forum.hibernate.org/viewtopic.ph ... cat+memory
but it doesn't offer any solutions but to go to latest releases of libaries which I think I have done.

What am I doing wrong?



Hibernate version:
3.1.2

Mapping documents:
Lots (I will post but I don't think this is the issue)

Code between sessionFactory.openSession() and session.close():


import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {

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

private static final SessionFactory sessionFactory;
private static final Configuration conFig;

static {
try {
// Create the SessionFactory
conFig = new Configuration().configure();
sessionFactory = conFig.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
//log.error("Initial SessionFactory creation failed.", ex);
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}

public static ThreadLocal session = new ThreadLocal();

public static Session currentSession() {
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() {
Session s = (Session) session.get();
if (s != null)
s.close();
session.set(null);
//sessionFactory.close();
}

public static String getUrl(){
return conFig.getProperty("hibernate.connection.url");
}

public static String getUsername(){
return conFig.getProperty("hibernate.connection.username");
}

public static String getPassword(){
return conFig.getProperty("hibernate.connection.password");
}

public static void setUrl(String in){
conFig.setProperty("hibernate.connection.url", in);
}

}




import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;


public class HibernateListener implements ServletContextListener {

public void contextInitialized(ServletContextEvent event) {
System.out.println("********************** Starting Context Here!!! ********************** ");
HibernateUtil.currentSession(); // Just call the static initializer of that class
}

public void contextDestroyed(ServletContextEvent event) {
System.out.println("********************** Stoping Context Here!!! ********************** ");
HibernateUtil.currentSession().close(); // Free all resources

//((PersistenceManager) event.getServletContext().getAttribute("persistenceManager")).close();
}
}






Name and version of the database you are using:
Oracle 9i


Last edited by ericchile on Wed Feb 22, 2006 12:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 5:54 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
No takers?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 12:20 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 4:59 pm
Posts: 31
So if Tomcat 5.5 doesn't work with Hibernate what should I use as my servlet engine?

Eric


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.