I have been working with Hibernate for some time now and have not had a problem like this with trying to establish a session. I am working on a portal enviornment, deploying into exo. Everything was working fine and now something seems to have changed and I cannot seem to pinpoint it.
I even tried creating a new whole new project in eclipse and I still seem to get the issue.
The error I get is this:
[portletcontainer] [ERROR] exception while initializing portlet : JupiterPortal
null
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at com.echostorm.jupiter.hibernate.AppSession.initialization(AppSession.java:60)
at com.echostorm.jupiter.hibernate.AppSession.getSession(AppSession.java:33)
at com.echostorm.jupiter.Portal.init(Portal.java:50)
at org.exoplatform.services.portletcontainer.impl.PortletApplicationProxy.init(PortletApplicationProxy.java:87)
at org.exoplatform.services.portletcontainer.impl.PortletApplicationProxy.getPortlet(PortletApplicationProxy.java:62)
at org.exoplatform.services.portletcontainer.impl.PortletApplicationHandler.process(PortletApplicationHandler.java:211)
at org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper.service(ServletWrapper.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
[...................................]
----------------------------------
Here is part of my portal code and as you can see it tries to get the session in the init, which gets called when someone hits the portal.
private static Log logger = LogFactory.getLog(Portal.class);
Session hibernateSession = null;
public void init(PortletConfig pConfig) throws PortletException
{
super.init(pConfig);
hibernateSession = AppSession.getSession();
logger.info("init");
}
----------------------
Here is my AppSession, which I tried leaving out all my classes, I didn't add them to the config thinking one of them was causing the issue and still nothing.
/*
* Created on Mar 18, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.echostorm.jupiter.hibernate;
/** Various Hibernate-related imports */
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class AppSession
{
private static Log logger = LogFactory.getLog(AppSession.class);
static String fileSep =
System.getProperty("file.separator");
/** We use this session factory to create our sessions */
public static SessionFactory sessionFactory;
public static Session getSession()
{
try
{
if (sessionFactory == null) initialization();
return sessionFactory.openSession();
} catch (Exception e)
{
logger.debug(e);
return null;
}
}
/**
* Loads the Hibernate configuration information, sets up the
* database and the Hibernate session factory.
*/
public static void initialization()
{
logger.info("Initialization");
try
{
Configuration myConfiguration = new Configuration();
// This is the code that updates the database to the
// current schema.
new SchemaUpdate(myConfiguration).execute(true, true);
// Sets up the session factory (used in the rest
// of the application).
logger.debug("About to build session");
sessionFactory = myConfiguration.buildSessionFactory();
} catch (Exception e)
{
logger.debug(e);
}
}
public static void main(String[] args)
{
initialization();
}
}
------------------------------------------------------
Here is my hibernate.properties file:
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
#hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver
hibernate.connection.url= jdbc:hsqldb:hsql://localhost:9001
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
#hibernate.show_sql=true
-----
And here is my logging code that I get from hibernate.
===== Saturday, April 2, 2005 4:53:42 PM US/Eastern =====
2005-04-02 16:53:52,387 [http-8080-Processor21] INFO AppSession - Initialization
2005-04-02 16:53:52,387 [http-8080-Processor21] INFO AppSession - Initialization
2005-04-02 16:53:52,452 [http-8080-Processor21] INFO Environment - Hibernate 2.1.8
2005-04-02 16:53:52,466 [http-8080-Processor21] INFO Environment - loaded properties from resource hibernate.properties: {hibernate.connection.username=sa, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:hsql://localhost:9001, hibernate.connection.driver_class=org.hsqldb.jdbcDriver}
2005-04-02 16:53:52,469 [http-8080-Processor21] INFO Environment - using CGLIB reflection optimizer
2005-04-02 16:53:52,472 [http-8080-Processor21] INFO Environment - using JDK 1.4 java.sql.Timestamp handling
2005-04-02 16:53:52,594 [http-8080-Processor21] INFO Dialect - Using dialect: net.sf.hibernate.dialect.HSQLDialect
2005-04-02 16:53:52,768 [http-8080-Processor21] INFO DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
2005-04-02 16:53:52,768 [http-8080-Processor21] INFO DriverManagerConnectionProvider - Hibernate connection pool size: 20
2005-04-02 16:53:52,777 [http-8080-Processor21] INFO DriverManagerConnectionProvider - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost:9001
2005-04-02 16:53:52,777 [http-8080-Processor21] INFO DriverManagerConnectionProvider - connection properties: {user=sa, password=}
2005-04-02 16:53:52,777 [http-8080-Processor21] INFO SchemaUpdate - Running hbm2ddl schema update
2005-04-02 16:53:52,777 [http-8080-Processor21] INFO SchemaUpdate - fetching database metadata
2005-04-02 16:53:53,242 [http-8080-Processor21] INFO SchemaUpdate - updating schema
2005-04-02 16:53:53,243 [http-8080-Processor21] INFO Configuration - processing one-to-many association mappings
2005-04-02 16:53:53,243 [http-8080-Processor21] INFO Configuration - processing one-to-one association property references
2005-04-02 16:53:53,243 [http-8080-Processor21] INFO Configuration - processing foreign key constraints
2005-04-02 16:53:53,247 [http-8080-Processor21] INFO SchemaUpdate - schema update complete
2005-04-02 16:53:53,252 [http-8080-Processor21] INFO DriverManagerConnectionProvider - cleaning up connection pool: jdbc:hsqldb:hsql://localhost:9001
2005-04-02 16:53:53,253 [http-8080-Processor21] DEBUG AppSession - About to build session
2005-04-02 16:53:53,253 [http-8080-Processor21] DEBUG AppSession - About to build session
2005-04-02 16:53:53,253 [http-8080-Processor21] INFO Configuration - processing one-to-many association mappings
2005-04-02 16:53:53,253 [http-8080-Processor21] INFO Configuration - processing one-to-one association property references
2005-04-02 16:53:53,253 [http-8080-Processor21] INFO Configuration - processing foreign key constraints
2005-04-02 16:53:53,271 [http-8080-Processor21] INFO Dialect - Using dialect: net.sf.hibernate.dialect.HSQLDialect
2005-04-02 16:53:53,297 [http-8080-Processor21] INFO SettingsFactory - Use outer join fetching: true
2005-04-02 16:53:53,297 [http-8080-Processor21] INFO DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
2005-04-02 16:53:53,297 [http-8080-Processor21] INFO DriverManagerConnectionProvider - Hibernate connection pool size: 20
2005-04-02 16:53:53,297 [http-8080-Processor21] INFO DriverManagerConnectionProvider - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost:9001
2005-04-02 16:53:53,298 [http-8080-Processor21] INFO DriverManagerConnectionProvider - connection properties: {user=sa, password=}
2005-04-02 16:53:53,310 [http-8080-Processor21] INFO TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
2005-04-02 16:53:53,545 [http-8080-Processor21] INFO SettingsFactory - Use scrollable result sets: true
2005-04-02 16:53:53,546 [http-8080-Processor21] INFO SettingsFactory - Use JDBC3 getGeneratedKeys(): false
2005-04-02 16:53:53,546 [http-8080-Processor21] INFO SettingsFactory - Optimize cache for minimal puts: false
2005-04-02 16:53:53,547 [http-8080-Processor21] INFO SettingsFactory - Query language substitutions: {}
2005-04-02 16:53:53,548 [http-8080-Processor21] INFO SettingsFactory - cache provider: net.sf.hibernate.cache.EhCacheProvider
2005-04-02 16:53:53,591 [http-8080-Processor21] INFO Configuration - instantiating and configuring caches
2005-04-02 16:53:53,699 [http-8080-Processor21] WARN Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: file:/Users/vince/Development/workspace/support/exo-tomcat/work/Catalina/localhost/JupiterPortal/loader/ehcache-failsafe.xml
Can anyone point me in the right direction please?
Thanks in advance..
Vince
|