From: Son To <son...@ya...> - 2002-03-31 05:59:13
|
I'm testing out hibernate-0.9.8 and there seems to be a bug. Here is the code to the relevant code in stateless session bean: --start----- public List findAllProduct() { Session session = getHibernateSession(); List productList = null; try { productList = session.find("select product from product in class openbx.domain.Product"); session.close(); } catch (Exception ex) { ex.printStackTrace(); } return productList; } private Connection getConnection() { ServiceLocator sL = ServiceLocator.getInstance(); Connection conn = null; try { DataSource ds = (DataSource)sL.lookup(sL.JDBC_DATASOURCE); conn = ds.getConnection(); } catch (Exception ex) { ex.printStackTrace(); } return conn; } private Session getHibernateSession() { Session s = null; try { Datastore ds = Hibernate.createDatastore(); ds = ds.storeFile("/home/son/mapping.xml"); SessionFactory sessionFactory = ds.buildSessionFactory(); Connection conn = getConnection(); s = sessionFactory.openSession(conn); } catch (Exception ex) { ex.printStackTrace(); } return s; } ----end--- The EJB container I'm using is JBoss2.4.4 and the database is postgresql7.1 Here is Jboss error log: [ERROR,Default] java.lang.NullPointerException [ERROR,Default] at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source) ...skip ...skip ...skip [ERROR,Default] java.lang.NullPointerException [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSession.getPreparedStatement(RelationalDatabaseSession.java:1774) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSession.prepareQueryStatement(RelationalDatabaseSession.java:717) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSession.find(RelationalDatabaseSession.java:760) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSession.find(RelationalDatabaseSession.java:710) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSession.find(RelationalDatabaseSession.java:620) This happens when I connect to the bean 32 times. It seems hibernate is not releasing the Connection even though I did a session.close(). When I try to connect to postgres directly using JDBC, I get Exception: java.sql.SQLException: Sorry, too many clients already So next I attempted to investigate why hibernate is not releasing the Connection. I compiled the source code distributed in hibernate-0.9.8.tar.gz. Everything compiled fine, but when I redeployed my bean using the hibernate.jar compiled from source, I get a different problem. Here is JBoss error message: ---- [ERROR,Default] javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: java.lang.NullPointerException [ERROR,Default] at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:946) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSessionFactory.<init>(RelationalDatabaseSessionFactory.java:102) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatabaseSessionFactory.<init>(RelationalDatabaseSessionFactory.java:135) [ERROR,Default] at cirrus.hibernate.impl.RelationalDatastore.buildSessionFactory(RelationalDatastore.java:50) at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:946) at cirrus.hibernate.impl.RelationalDatabaseSessionFactory.<init>(RelationalDatabaseSessionFactory.java:102) at cirrus.hibernate.impl.RelationalDatabaseSessionFactory.<init>(RelationalDatabaseSessionFactory.java:135) at cirrus.hibernate.impl.RelationalDatastore.buildSessionFactory(RelationalDatastore.java:50) --- I got the same result when compiling from code in CVS. So the question for Gavin is what is the source code for hibernate.jar that id distributed with hibernate0.9.8.tar.gz? thanks, Son __________________________________________________ Do You Yahoo!? Yahoo! Greetings - send holiday greetings for Easter, Passover http://greetings.yahoo.com/ |