Unable to build EntityManagerFactory
Bonjour,
Je debute sur les JPA et je pense avoir un probleme simple sur lequel je bloque pourtant depuis trop longtemps. Mon probleme se situe au lancement simple d'une classe de base pour tester la persistence.
J'ai une base hsql qui tourne correctement:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
/usr/local/jboss-6.0.0.Final$ java -cp common/lib/hsqldb.jar org.hsqldb.Server
[Server@1975b59]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@1975b59]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@1975b59]: Startup sequence initiated from main() method
[Server@1975b59]: Loaded properties from [/usr/local/jboss-6.0.0.Final/server.properties]
[Server@1975b59]: Initiating startup sequence...
[Server@1975b59]: Server socket opened successfully in 7 ms.
[Server@1975b59]: Database [index=0, id=0, db=file:./jpatest, alias=jpatest] opened sucessfully in 251 ms.
[Server@1975b59]: Startup sequence completed in 261 ms.
[Server@1975b59]: 2011-03-02 13:02:58.730 HSQLDB server 1.8.0 is online |
Voici aussi mon persistence.xml:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost/jpatest"/>
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence> |
Lorsque j'apporte une modification au persistence.xml, j'ai une erreur de plus, je presume donc que la connexion a la bd s'opere correctement.
Pourtant j'obtiens toujours la meme erreur :(:(:
Code:
1 2 3 4 5 6
|
javax.persistence.PersistenceException: [PersistenceUnit: sample] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
(...)
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110) |
Peut-etre que cette erreur vient de mon code Adresse.java:
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 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
|
@Entity
@Table(name="ADDRESS")
public class Adresse implements Serializable {
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE) @Column(name = "ID")
private long idAdresse;
@Column(name = "TELEPHONENUMBER", length=20)
private String telephone;
@Column(name = "STREETNUMBER", length=10)
private String numeroVoie;
@Column(name = "STREETNAME", length=38)
private String nomVoie;
@Column(name = "ADDRESSLINE5", length=38)
private String mentionSpecial;
@Column(name = "ZIP", length=10)
private String codePostal;
@Column(name = "CITY", length=38)
private String commune;
@Column(name = "COUNTRY", nullable = false, length=38)
private String pays;
public Adresse() {
super();
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getNumeroVoie() {
return numeroVoie;
}
public void setNumeroVoie(String numeroVoie) {
this.numeroVoie = numeroVoie;
}
public String getNomVoie() {
return nomVoie;
}
public void setNomVoie(String nomVoie) {
this.nomVoie = nomVoie;
}
public String getMentionSpecial() {
return mentionSpecial;
}
public void setMentionSpecial(String mentionSpecial) {
this.mentionSpecial = mentionSpecial;
}
public String getCodePostal() {
return codePostal;
}
public void setCodePostal(String codePostal) {
this.codePostal = codePostal;
}
public String getCommune() {
return commune;
}
public void setCommune(String commune) {
this.commune = commune;
}
public String getPays() {
return pays;
}
public void setPays(String pays) {
this.pays = pays;
}
public long getIdAdresse() {
return idAdresse;
}
} |
TestAdresse.java:
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 32 33 34 35 36 37 38 39 40 41 42 43
|
public class TestAdresse {
private static EntityManager em;
private static EntityManagerFactory emf;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
emf = Persistence.createEntityManagerFactory("sample");
em = emf.createEntityManager();
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
em.close();
emf.close();
}
@Test(timeout=1000)
public void testMinimumAdresse() {
EntityTransaction tx = em.getTransaction();
tx.begin();
Adresse monAdresse=new Adresse();
monAdresse.setPays("FRANCE");
em.persist(monAdresse);
tx.commit();
long monId = monAdresse.getIdAdresse();
assertNotNull("Id not null", monId);
Adresse monAdresseRetrouve = em.find(Adresse.class, monId);
assertNotNull("Adresse from database", monAdresseRetrouve);
assertEquals("getPays", "FRANCE", monAdresseRetrouve.getPays());
assertNull("Code Postal Null", monAdresseRetrouve.getCodePostal());
assertNull("Commune Null", monAdresseRetrouve.getCommune());
assertNull("MentionSpecial Null", monAdresseRetrouve.getMentionSpecial());
}
} |
qui sont pourtant les codes d'un tuto que je suis scrupuleusement...
Je n'ai plus d'idee pour debugger/debloquer cette erreur, j'espere que vous pourrez me guider.
Merci