Hi, I am testing my hibernate stuff here with a junit test in net beans but I am getting a java.lang.NullPointerException when my HibernateUtil.class gets to this point,
Code:
sessionFactory = cfg.buildSessionFactory();
It is loading in all my ...hbm.xml mapping files successfully but flaking when trying to create a session.
Code:
java.lang.NullPointerException
at net.sf.hibernate.cfg.Configuration$1.getIdentifierType(Configuration.java:113)
at net.sf.hibernate.type.ManyToOneType.getReferencedType(ManyToOneType.java:23)
at net.sf.hibernate.type.ManyToOneType.getColumnSpan(ManyToOneType.java:31)
at net.sf.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:192)
at net.sf.hibernate.mapping.Collection.validate(Collection.java:255)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:635)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:799)
my hibernate.cfg.xml file is sitting in my default package location,
this is my file,
Code:
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="dialect">net.sf.hibernate.dialect.SybaseAnywhereDialect</property>
<property name="connection.url">jdbc:sybase:Tds:localhost:2638?ServiceName=jetts</property>
<property name="connection.username">jetts</property>
<property name="connection.password">rsl</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<!-- mapping files -->
All my mapping files are in here
</session-factory>
</hibernate-configuration>
I am using hibernate 2.1
I have checked the FAQ on this and searched the forums but have not been able to identify a possible cause to this.
This is mu HibernateUtil class
Code:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
private static Log log = LogFactory.getLog(HibernateUtil.class);
static {
try {
// Create the SessionFactory
Configuration cfg = new Configuration();
cfg.configure();
sessionFactory = cfg.buildSessionFactory();
} catch (Throwable ex) {
log.error("Initial SessionFactory creation failed.",ex);
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession(){
Session session=null;
try {
session = (Session) sessionFactory.openSession();
}
catch (HibernateException e) {
log.error(e.getMessage(),e);
}
return session;
}
public static Session currentSession() {
return getSession();
}
public static void closeSession(Session session) {
try {
session.close();
} catch (HibernateException e) {
log.error(e.getMessage(),e);
}
}
}
I really need to get this solved today, I was in the weekend trying to fix this problem but had no success, very painful.
Thank you for your help on this issue.
John.