Hy everyone,
I have to do a project for my studies with hibernate. So I've just tried to create a little application to see if I can insert some values in my database.
Here is my application tree :
My ContactInsert.java :
Code:
package org.hibernate;
import org.hibernate.tables.Contact;
import org.hibernate.util.HibernateUtil;
public class ContactInsert {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Contact contact = new Contact();
contact.setId(1);
contact.setFirstName("bibi");
contact.setLastName("bubu");
contact.setEmail("bibi@bubu.fr");
session.save(contact);
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();
}
}
I have past the same HibernateUtil class as the tutorial.
When I execute my main class I get this error :
Code:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.hibernate.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
at org.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:8)
at org.hibernate.ContactInsert.main(ContactInsert.java:14)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at org.hibernate.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
... 2 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Can you please help me.
Many thanks