Bonjour,
j'essaye d'utiliser JPA/Toplink pour le mapping O/R, mais j'ai l'erreur suivante:
et voici mon fichier persistence.xml:
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 Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named jpa: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory: oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException Local Exception Stack: Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7 Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException Exception Description: predeploy for PersistenceUnit [jpa] failed. Internal Exception: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be cast to java.lang.Class at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143) at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at DAO.Dao.init(Dao.java:34) at Main.Lancement.main(Lancement.java:29) Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException Exception Description: predeploy for PersistenceUnit [jpa] failed. Internal Exception: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be cast to java.lang.Class at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:643) at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:171) at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:239) at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:255) at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:155) ... 4 more Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException Exception Description: predeploy for PersistenceUnit [jpa] failed. Internal Exception: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be cast to java.lang.Class at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:228) ... 9 more Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be cast to java.lang.Class at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataHelper.getReturnTypeFromGeneric(MetadataHelper.java:603) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataAccessibleObject.getReferenceClassFromGeneric(MetadataAccessibleObject.java:141) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.CollectionAccessor.getReferenceClass(CollectionAccessor.java:175) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:287) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:579) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:512) at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:246) at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:370) at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:607) ... 8 more The following providers: oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider Returned null to createEntityManagerFactory. at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at DAO.Dao.init(Dao.java:34) at Main.Lancement.main(Lancement.java:29) Java Result: 1 BUILD SUCCESSFUL (total time: 11 seconds)
le code qui me permet de créer un EntityMAnager:
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 <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" 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"> <persistence-unit name="jpa" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <class>Metier.Enseignant.Enseignant</class> <class>Metier.Etudes.Discipline</class> <class>Metier.Etudes.Domaine</class> <class>Metier.Etudes.Module</class> <class>Metier.Etudes.UE</class> <class>Metier.Etudiant.Cursus</class> <class>Metier.Etudiant.Etats.AbstractEtatEtudiant</class> <class>Metier.Etudiant.Etudiant</class> <class>Metier.Notes.ReleveNotes</class> <class>Metier.Promotion.ASemestre</class> <class>Metier.Promotion.Annee</class> <class>Metier.Promotion.Cours</class> <class>Metier.Promotion.Epreuve</class> <class>Metier.Promotion.Etats.AbstractEtatPromotion</class> <class>Metier.Promotion.EtatsAnnee.AbstractEtatAnnee</class> <class>Metier.Promotion.EtatsSemestre.AbstractEtatSemestre</class> <class>Metier.Promotion.Promotion</class> <class>Metier.Promotion.Regles</class> <class>Metier.Promotion.Semestre</class> <properties> <property name="toplink.jdbc.user" value=""/> <property name="toplink.jdbc.password" value=""/> <property name="toplink.jdbc.url" value="jdbc:derby://localhost:1527/JStudentDB"/> <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/> <property name="toplink.ddl-generation" value="create-tables"/> </properties> </persistence-unit> </persistence>
j'ai bien mis les différentes librairies dans le class-path (META-INF aussi qui contient persistence.xml)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 public void init(){ System.out.println("init() ..."); fabrique = Persistence.createEntityManagerFactory("jpa"); contextePersistance = fabrique.createEntityManager(); System.out.println("Fabrique ="+fabrique); System.out.println("contexte ="+contextePersistance); getDaoEtudiant(); getDaoEnseignant(); getDaoPromotion(); }
J'ai beau cherché sur Google/developpez, j'ai rien trouvé![]()
Partager