-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Urgent please help
PostPosted: Mon Aug 08, 2005 4:19 am 
Newbie

Joined: Thu Jul 07, 2005 6:59 am
Posts: 13
Location: Derry Northern Ireland
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:12 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
There might be something wrong with the identifiers in your persistent classes.

Try to comment out some of your classes in your hibernate.cfg.xml to find the error.

Best regards
Sven


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.