ERROR:->
==============================================
0 [main] INFO TestClient - creating honey
31 [main] INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.8
31 [main] INFO net.sf.hibernate.cfg.Environment - hibernate.properties not found
47 [main] INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
47 [main] INFO net.sf.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
47 [main] INFO net.sf.hibernate.cfg.Configuration - configuring from resource: E:Program Files/Microsoft SQL Server/MSSQL.1/MSSQL/JOBS/hibernate.cfg.xml
47 [main] INFO net.sf.hibernate.cfg.Configuration - Configuration resource: E:Program Files/Microsoft SQL Server/MSSQL.1/MSSQL/JOBS/hibernate.cfg.xml
47 [main] WARN net.sf.hibernate.cfg.Configuration - E:Program Files/Microsoft SQL Server/MSSQL.1/MSSQL/JOBS/hibernate.cfg.xml not found
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.HibernateException: E:Program Files/Microsoft SQL Server/MSSQL.1/MSSQL/JOBS/hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:886)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:910)
at de.laliluna.example.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:48)
at de.laliluna.example.TestClient.createHoney(TestClient.java:42)
at de.laliluna.example.TestClient.main(TestClient.java:24)
Exception in thread "main" java.lang.NullPointerException
at de.laliluna.example.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:56)
at de.laliluna.example.TestClient.createHoney(TestClient.java:42)
at de.laliluna.example.TestClient.main(TestClient.java:24)
================================================
package de.laliluna.example;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.cfg.Configuration;
public class HibernateSessionFactory {
private static net.sf.hibernate.SessionFactory sessionFactory;
public static Session currentSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || ! session.isConnected()) {
if (sessionFactory == null) {
try {
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
}
catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
session = sessionFactory.openSession();
threadLocal.set(session);
}
return session;
}
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close();
}
}
private HibernateSessionFactory() {
}
}

Ask A New Question
Reply





MultiQuote




|