Message : JPA, MySQL et Tomcat
Utilisateur : bpmfouka
Infraction : Non-utilisation des balises CODE
Points : 0

Note administrative :
Message pour l'utilisateur :
L'équipe de modération a remarqué que dans votre message "JPA, MySQL et Tomcat", quand vous mettez un bout de votre code vous ne mettez pas les balises CODE.

Nous avons ajouté les balises "code" afin que vos messages soient plus lisibles.
Nous vous demandons donc de prendre l'habitude d'utiliser ces balises.
Pour cela il vous suffit d'utiliser le bouton code (#) juste au dessus de la zone de saisie des messages comme l'illustre cette animation :



Merci de votre compréhension.

Message original :
Bonjour,
J'ai implémenté un exemple de projet web dynamic pour tester JPA et Mysql mais rien ne marche à chaque exécution ce message d'erreur :

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named modeliser
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.team.formation.modele.test.JpersistenceTest.initEntityManager(JpersistenceTest.java:37)
at com.team.formation.modele.test.JpersistenceTest.main(JpersistenceTest.java:28)
*** Voici mon fichier persistence.xml :

Code xml : 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
<persistence-unit name="modeliser" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.team.formation.model.ClientTest</class>
<class>com.team.formation.model.ArticlesTest</class>
<class>com.team.formation.model.CommandeTest</class>
<class>com.team.formation.model.LigneCommandeTest</class>
 
<properties>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost/formation" />
<property name="eclipselink.jdbc.user" value="formation" />
<property name="eclipselink.jdbc.password" value="" />
 
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>

*** Ma classe principale:

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
59
60
61
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceException;

import com.team.formation.model.ClientTest;

/**
* @author MFOUKA MOKONO
*
*/
public class JpersistenceTest {

private EntityManagerFactory emf;
private EntityManager em;
private String PERSISTENCE_UNIT_NAME = "modeliser";
/**
* @param args
*/
public static void main(String[] args) {

JpersistenceTest persistenceTest = new JpersistenceTest();
persistenceTest.initEntityManager();
persistenceTest.create();
persistenceTest.closeEntityManager();

}

private void initEntityManager() {

//	 try{
emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
em = emf.createEntityManager();
//	 }catch(PersistenceException pEX){
//	 pEX.getStackTrace();
//	 System.out.print("Erreur : " + pEX.getMessage());
//	 }

}

private void closeEntityManager() {
emf.close();
em.close();
}

private void create() {
em.getTransaction().begin();
ClientTest clientTest = new ClientTest();
clientTest.setIdClient(1);
clientTest.setNom("MOKONO");
clientTest.setPrenom("Brice");
clientTest.setLogin("test");
clientTest.setPassword("essai");
clientTest.setAdresse("12 Avenue Matsoua Bacongo");
clientTest.setEmail("bpmfouka@yahoo.fr");
clientTest.setTelephone(0610320236);

em.getTransaction().commit();
}

}
**** Mes entités :

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@Entity
@Table(name="ArticlesTest")
public class ArticlesTest implements Serializable {

/**
* 
*/
private static final long serialVersionUID = 3514550600993369401L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int numeroArticle;
private String designation;
private float prixUnitaire;

public ArticlesTest() {
super();
}

/**
* @return the numeroArticle
*/
public int getNumeroArticle() {
return numeroArticle;
}

/**
* @param numeroArticle the numeroArticle to set
*/
public void setNumeroArticle(int numeroArticle) {
this.numeroArticle = numeroArticle;
}

/**
* @return the designation
*/
public String getDesignation() {
return designation;
}

/**
* @param designation the designation to set
*/
public void setDesignation(String designation) {
this.designation = designation;
}

/**
* @return the prixUnitaire
*/
public float getPrixUnitaire() {
return prixUnitaire;
}

/**
* @param prixUnitaire the prixUnitaire to set
*/
public void setPrixUnitaire(float prixUnitaire) {
this.prixUnitaire = prixUnitaire;
}

/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((designation == null) ? 0 : designation.hashCode());
result = prime * result + numeroArticle;
result = prime * result + Float.floatToIntBits(prixUnitaire);
return result;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ArticlesTest other = (ArticlesTest) obj;
if (designation == null) {
if (other.designation != null)
return false;
} else if (!designation.equals(other.designation))
return false;
if (numeroArticle != other.numeroArticle)
return false;
if (Float.floatToIntBits(prixUnitaire) != Float
.floatToIntBits(other.prixUnitaire))
return false;
return true;
}

}
////////////:::::
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
@Entity
@Table(name="ClientTest")
public class ClientTest implements Serializable {

/**
* 
*/
private static final long serialVersionUID = -614513751770847367L;

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int idClient;
private String nom;
private String prenom;
private String login;
private String password;
private String adresse;
private String email;
private double telephone;

public ClientTest() {
super();
}

/**
* @return the idClient
*/
public int getIdClient() {
return idClient;
}
/**
* @param idClient the idClient to set
*/
public void setIdClient(int idClient) {
this.idClient = idClient;
}
/**
* @return the nom
*/
public String getNom() {
return nom;
}
/**
* @param nom the nom to set
*/
public void setNom(String nom) {
this.nom = nom;
}
/**
* @return the prenom
*/
public String getPrenom() {
return prenom;
}
/**
* @param prenom the prenom to set
*/
public void setPrenom(String prenom) {
this.prenom = prenom;
}
/**
* @return the login
*/
public String getLogin() {
return login;
}
/**
* @param login the login to set
*/
public void setLogin(String login) {
this.login = login;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the adresse
*/
public String getAdresse() {
return adresse;
}
/**
* @param adresse the adresse to set
*/
public void setAdresse(String adresse) {
this.adresse = adresse;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the telephone
*/
public double getTelephone() {
return telephone;
}
/**
* @param telephone the telephone to set
*/
public void setTelephone(double telephone) {
this.telephone = telephone;
}

/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((adresse == null) ? 0 : adresse.hashCode());
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + idClient;
result = prime * result + ((login == null) ? 0 : login.hashCode());
result = prime * result + ((nom == null) ? 0 : nom.hashCode());
result = prime * result
+ ((password == null) ? 0 : password.hashCode());
result = prime * result + ((prenom == null) ? 0 : prenom.hashCode());
long temp;
temp = Double.doubleToLongBits(telephone);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ClientTest other = (ClientTest) obj;
if (adresse == null) {
if (other.adresse != null)
return false;
} else if (!adresse.equals(other.adresse))
return false;
if (email == null) {
if (other.email != null)
return false;
} else if (!email.equals(other.email))
return false;
if (idClient != other.idClient)
return false;
if (login == null) {
if (other.login != null)
return false;
} else if (!login.equals(other.login))
return false;
if (nom == null) {
if (other.nom != null)
return false;
} else if (!nom.equals(other.nom))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (prenom == null) {
if (other.prenom != null)
return false;
} else if (!prenom.equals(other.prenom))
return false;
if (Double.doubleToLongBits(telephone) != Double
.doubleToLongBits(other.telephone))
return false;
return true;
}

}
//////////////::
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
@Entity
@Table(name="CommandeTest")
public class CommandeTest implements Serializable {

/**
* 
*/
private static final long serialVersionUID = 4391597190955973559L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int numeroCommande;
@OneToMany
//	@JoinTable(name="ClientTest", @JoinColumn=@JoinColumn(name="idClient", referencedColumnName="idClient"))
@JoinColumn(name="idClient")
private int idClient;
private Date dateCommande;

public CommandeTest() {
super();
}

/**
* @return the numeroCommande
*/
public int getNumeroCommande() {
return numeroCommande;
}

/**
* @param numeroCommande the numeroCommande to set
*/
public void setNumeroCommande(int numeroCommande) {
this.numeroCommande = numeroCommande;
}

/**
* @return the idClient
*/
public int getIdClient() {
return idClient;
}

/**
* @param idClient the idClient to set
*/
public void setIdClient(int idClient) {
this.idClient = idClient;
}

/**
* @return the dateCommande
*/
public Date getDateCommande() {
return dateCommande;
}

/**
* @param dateCommande the dateCommande to set
*/
public void setDateCommande(Date dateCommande) {
this.dateCommande = dateCommande;
}

/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((dateCommande == null) ? 0 : dateCommande.hashCode());
result = prime * result + idClient;
result = prime * result + numeroCommande;
return result;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CommandeTest other = (CommandeTest) obj;
if (dateCommande == null) {
if (other.dateCommande != null)
return false;
} else if (!dateCommande.equals(other.dateCommande))
return false;
if (idClient != other.idClient)
return false;
if (numeroCommande != other.numeroCommande)
return false;
return true;
}

}
////////:::::
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@Entity
@Table(name="LigneCommandeTest")
public class LigneCommandeTest implements Serializable {

/**
* 
*/
private static final long serialVersionUID = 7725471434507308774L;

@ManyToOne
@JoinColumn(name="numeroCommande")
private List<CommandeTest> numeroCommande = new ArrayList<CommandeTest>();
@ManyToOne
@JoinColumn(name="numeroArticle")
private List<ArticlesTest> numeroArticle = new ArrayList<ArticlesTest>();
@Id
private int id;
private int Quantite;

/**
* 
*/
public LigneCommandeTest() {
super();
}

/**
* @return the numeroCommande
*/
public List<CommandeTest> getNumeroCommande() {
return numeroCommande;
}

/**
* @param numeroCommande the numeroCommande to set
*/
public void setNumeroCommande(List<CommandeTest> numeroCommande) {
this.numeroCommande = numeroCommande;
}

/**
* @return the numeroArticle
*/
public List<ArticlesTest> getNumeroArticle() {
return numeroArticle;
}

/**
* @param numeroArticle the numeroArticle to set
*/
public void setNumeroArticle(List<ArticlesTest> numeroArticle) {
this.numeroArticle = numeroArticle;
}

/**
* @return the id
*/
public int getId() {
return id;
}

/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}

/**
* @return the quantite
*/
public int getQuantite() {
return Quantite;
}

/**
* @param quantite the quantite to set
*/
public void setQuantite(int quantite) {
Quantite = quantite;
}

/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Quantite;
result = prime * result + id;
result = prime * result
+ ((numeroArticle == null) ? 0 : numeroArticle.hashCode());
result = prime * result
+ ((numeroCommande == null) ? 0 : numeroCommande.hashCode());
return result;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
LigneCommandeTest other = (LigneCommandeTest) obj;
if (Quantite != other.Quantite)
return false;
if (id != other.id)
return false;
if (numeroArticle == null) {
if (other.numeroArticle != null)
return false;
} else if (!numeroArticle.equals(other.numeroArticle))
return false;
if (numeroCommande == null) {
if (other.numeroCommande != null)
return false;
} else if (!numeroCommande.equals(other.numeroCommande))
return false;
return true;
}

}
-> Si bien que j'ai installé les jars suivants sous eclipse :
eclipselink-jpa-modelgen.jar, mysql-connector-java-5.bin.jar et javax.persistence.jar.

*****Est-il important d'ajouter le fichier orm.xml quand on utilise déjà les annotations dans les classes entités???