Erreur "java.lang.NoSuchMethodError: main Exception in thread "main""
Bonjour,
J'utilise Hibernate dans mon projet J2EE avec Eclipse.
Après la synchronisation, j'essaye de faire la connexion aux tables dans les classes DAO dont voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| package Modele.dao;
import Modele.Client;
import java.util.*;
import org.hibernate.Session;
import org.hibernate.Transaction;
import Modele.Client;
import Modele.dao.HibernateUtil;
import Modele.base.BaseClientDAO;
/**
* This class has been automatically generated by Hibernate Synchronizer.
* For more information or documentation, visit The Hibernate Synchronizer page
* at http://www.binamics.com/hibernatesync or contact Joe Hudson at joe@binamics.com.
*
* This is the object class that relates to the client table.
* Any customizations belong here.
*/
public class ClientDAO extends BaseClientDAO {
public static void main(String [] args){
Session session = (Session) HibernateUtil.getSessionFactory();
Transaction tx = session.beginTransaction();
Client client = new Client();
tx.commit();
session.close();
}
} |
Le fichier de session :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| package Modele.dao;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static
{
try
{
// Crée lobjet SessionFactory à partir de hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch (Throwable ex)
{
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory()
{
return sessionFactory;
}
} |
J'obtiens l'erreur suivante :
Citation:
java.lang.NoSuchMethodError: main Exception in thread "main"
Quelqu'un saurait-il m'expliquer d'où peut venir cette erreur ?
Merci d'avance pour votre aide.