Hello All,
I am trying to deploy a web application which was developed using java 1.6 and tomcat on weblogic 10.3.0.0 server.
My hibernate.cfg.xml file contains --
Code:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="hibernate.connection.username">NSE</property>
<property name="hibernate.connection.password">nse</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.connection.release_mode">auto</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">false</property>
<property name="format_sql">true</property>
<property name="current_session_context_class">thread</property>
<mapping resource="NSE.hbm.xml" />
</session-factory>
</hibernate-configuration>
I also have a connection.property file which contains --
Code:
conString=jdbc:oracle:thin:@localhost:1521:XE
driver=oracle.jdbc.driver.OracleDriver
Dialect=org.hibernate.dialect.OracleDialect
username=usrName
password=passWd
I have a helper class which helps me to get a new session object using the connection.property file . The contents are
Code:
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
static final Logger logger = Logger.getLogger(HibernateUtil.class);
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
Properties properties = new Properties();
properties.load(Thread.currentThread().getContextClassLoader()
.getResourceAsStream("connection.properties"));
Configuration cfg = new Configuration();
cfg = cfg.configure();
cfg.setProperty("hibernate.connection.driver_class", properties
.getProperty("driver"));
cfg.setProperty("hibernate.connection.url", properties
.getProperty("conString"));
cfg.setProperty("hibernate.connection.username", properties
.getProperty("username"));
cfg.setProperty("hibernate.connection.password", properties
.getProperty("password"));
cfg.setProperty("hibernate.dialect", properties
.getProperty("Dialect"));
return cfg.buildSessionFactory();
} catch (Throwable ex) {
logger.error(ex.toString());
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
The application is running fine in tomcat 6 but when I try to deploy it on weblogic 10.3.0.0 I get the following error --
Code:
java.lang.ExceptionInInitializerError
at login.LoginVerify.doPost(LoginVerify.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.lang.NullPointerException
at helper.HibernateUtil.buildSessionFactory(HibernateUtil.java:43)
at helper.HibernateUtil.(HibernateUtil.java:18)
Am I missing something in my hibernate.cfg.xml ? Any help will be greatly appreciated!