je développe une application avec maven et hibernate. Or, J'obtiens l'erreur suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
Exception in thread "main" java.lang.ExceptionInInitializerError
	at Util.HibernateUtil.<clinit>(HibernateUtil.java:18)
	at Dao.Service.addProduit(Service.java:9)
	at Util.Test.main(Test.java:20)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
	at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:165)
	at Util.HibernateUtil.<clinit>(HibernateUtil.java:14)
	... 2 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
	at java.net.URLClassLoader$1.run(Unknown Source)
	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)
	... 10 more
ci joint les deux classes, leurs fichiers hbm.xml respectivement, la classe service, le fichier HibernateUtil, Hibernate.cfg.xml ainsi que le POM.xml et enfin une classe de teste
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package Dao;
 
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
public class Categorie {
	private Long idCategorie;
	private String titre;
	private String Description;
	private Date dateAjout;
	private Set<Produit> produits = new HashSet<Produit>();
 
 
	public Set<Produit> getProduits() {
		return produits;
	}
	public void setProduits(Set<Produit> produits) {
		this.produits = produits;
	}
	public Categorie() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Categorie(String titre, String description, Date dateAjout) {
		super();
		this.titre = titre;
		Description = description;
		this.dateAjout = dateAjout;
	}
	public Long getIdCategorie() {
		return idCategorie;
	}
	public void setIdCategorie(Long idCategorie) {
		this.idCategorie = idCategorie;
	}
	public String getTitre() {
		return titre;
	}
	public void setTitre(String titre) {
		this.titre = titre;
	}
	public String getDescription() {
		return Description;
	}
	public void setDescription(String description) {
		Description = description;
	}
	public Date getDateAjout() {
		return dateAjout;
	}
	public void setDateAjout(Date dateAjout) {
		this.dateAjout = dateAjout;
	}
 
 
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package Dao;
 
public class Produit {
 
	private Long idProduit;
	private String Nom;
	private String description;
	private Double prix;
 
 
	public Produit(String nom, String description, Double prix) {
		super();
		Nom = nom;
		this.description = description;
		this.prix = prix;
	}
	public Produit() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Long getIdProduit() {
		return idProduit;
	}
	public void setIdProduit(Long idProduit) {
		this.idProduit = idProduit;
	}
	public String getNom() {
		return Nom;
	}
	public void setNom(String nom) {
		Nom = nom;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Double getPrix() {
		return prix;
	}
	public void setPrix(Double prix) {
		this.prix = prix;
	}
 
 
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 
<hibernate-mapping>
 
<class name="Dao.Categorie" table="CATEGORIE">
 
	<id name="idCategorie" column="ID_CATEGORIE">
		<generator class="native"></generator>
	</id>
 
	<property name="titre" column="TITRE"></property>
	<property name="description" column="DESCRPTION"></property>
	<property name="dateAjout" column="DATE_AJOUT"></property>
 
	<set name="produits" table="CAT_PROD">
		<key column="ID_CATEGORIE"> </key>
		<many-to-many class="Dao.Produit" column="ID_PRODUIT"></many-to-many>
	</set>
</class>
 
</hibernate-mapping>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 
<hibernate-mapping>
 
<class name="Dao.Produit" table="PRODUITS">
 
	<id name="idProduit" column="ID_PRODUIT">
		<generator class="native"></generator>
	</id>
 
	<property name="nom" column="NOM"></property>
	<property name="description" column="DESCRPTION"></property>
	<property name="prix" column="PRIX"></property>
</class>
 
</hibernate-mapping>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package Dao;
import org.hibernate.Session;
 
import Util.HibernateUtil;
 
public class Service {
 
	public void addProduit(Produit p){
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.save(p);
		session.getTransaction().commit();
	}
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
package Util;
 
import org.hibernate.*;
import org.hibernate.cfg.*;
 
 
 
public class HibernateUtil {
    public static final SessionFactory sessionFactory;
 
    static {
        try {
            // Création de la sessionFactory Ã* partir de(hibernate.cfg.xml) 
            sessionFactory =  new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Log the exception. 
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Util;
 
import org.hibernate.Session;
 
import Dao.Produit;
import Dao.Service;
 
public class Test {
 
	/**
         * @param args
         */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
 
 
 
		Service s = new Service();
		Produit p = new Produit("pc", "sony",(double) 7000);
		s.addProduit(p);
	}
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
 
 
 
    <!-- Database connection settings -->
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gestprod</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password"></property>
 
    <!-- JDBC connection pool -->
    <property name="connection.pool.size">1</property>
 
    <!-- SQL dialect -->
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
 
    <!-- Enable Hibernate's automatic session context management -->
    <property name="hibernate.current_session_context_class">thread</property>
 
 
    <!-- Disable the second-level cache -->
    <property name="cache.provider_class">org.Hibenate.cache.NoCacheProvider</property>
 
    <!-- Echo all executed SQL to sdout -->
    <property name="hibernate.show_sql">true</property>
 
	<!-- Drop and re-create the database shema on startup --> 
	<property name="hbm2dll.auto">create</property>
 
	<mapping resource="dao/Categorie.hbm.xml"/>
	<mapping resource="dao/Produit.hbm.xml"/>   
 
 
 
  </session-factory>
</hibernate-configuration>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>jpa</groupId>
	<artifactId>jpa</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.6</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>3.5.6-Final</version>
		</dependency>
 
 
 
 
	</dependencies>
 
</project>
Quelqu'un aurait une idée ? merci d'avance !