Hi, I'm using
Hibernate 3.2.0 with Java 5 and Eclipse.
PostgreSQL 8.2
Win XP
I don't have any compile errors, but at runtime occurs the following error:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError:
javax/persistence/SqlResultSetMappings
Exception in thread "main" java.lang.ExceptionInInitializerError
at booksonline.util.HibernateUtil.<clinit>(HibernateUtil.java:16)
at booksonline.kap3.SaveUser.main(SaveUser.java:11)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/SqlResultSetMappings
at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.<clinit>(EJB3OverridenAnnotationReader.java:135)
at org.hibernate.reflection.java.JavaXAnnotatedElement.<init>(JavaXAnnotatedElement.java:22)
at org.hibernate.reflection.java.JavaXClass.<init>(JavaXClass.java:24)
at org.hibernate.reflection.java.JavaXFactory$1.caseClass(JavaXFactory.java:179)
at org.hibernate.reflection.java.JavaXFactory$1.caseClass(JavaXFactory.java:188)
at org.hibernate.reflection.java.generics.TypeSwitch.doSwitch(TypeSwitch.java:19)
at org.hibernate.reflection.java.JavaXFactory.toXClass(JavaXFactory.java:173)
at org.hibernate.reflection.java.JavaXFactory.toXClass(JavaXFactory.java:83)
at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:133)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:458)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at booksonline.util.HibernateUtil.<clinit>(HibernateUtil.java:12)
... 1 more
I use the following main class:
public class SaveUser {
public static void main(String[] args) {
User user = new User("Horst", "Hans", "Horst@Hans.de");
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
session.persist(user);
tx.commit();
session.close();
}
}
I don't know why there can't be initialized a SessionFactory.
Can anybody help me out?
|