je suis entrain de developper une application jee (ejb3) pour inserer des données dans une base de donées
pour se faire j'ai utilisé my sql comme db et toplink comme une ORM
lors de l'execution de la classe VolFacade responsable des actions de persistence de l'entityBean Vol

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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package ejb;
 
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;
import javax.transaction.UserTransaction;
 
/**
 *
 * @author Administrateur
 */
@Stateless
public class VolFacade implements VolFacadeLocal {
 
@Resource
private UserTransaction utx = null;
@PersistenceUnit(unitName = "OACA-ejbPU")
private EntityManagerFactory emf = null;
 
private static final String JPA_UNIT_NAME = "OACA-ejbPU";
private EntityManager entityManager=null;
long n=0;
public EntityManager getEntityManager() {
if (entityManager == null) {
entityManager = Persistence.createEntityManagerFactory(JPA_UNIT_NAME).createEntityManager();
}
return entityManager;
}
 
public void create(long n) throws Exception {
 
try {
    Vol voll = new Vol(n);
voll.setDepart("dddddd");
voll.setDestination("fgfdd");
 
entityManager = getEntityManager();
 
entityManager.persist(voll);
 
utx.commit();
} finally {
if (entityManager != null) {
entityManager.close();
}
}
}
public static void main(String[] args){
try {
 
VolFacade vf = new VolFacade();
vf.create(5);
} catch (Exception ex) {
Logger.getLogger(VolFacade.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
mais a l'excution voici l'erreur qui apparait

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
javax.persistence.PersistenceException: Exception [TOPLINK-7060] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot acquire data source [voldb].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:239)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
        at ejb.VolFacade.getEntityManager(VolFacade.java:35)
        at ejb.VolFacade.create(VolFacade.java:47)
        at ejb.VolFacade.main(VolFacade.java:62)
Caused by: Exception [TOPLINK-7060] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot acquire data source [voldb].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at oracle.toplink.essentials.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:373)
        at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:135)
        at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
        at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
        at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
        ... 7 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:385)
        at javax.naming.InitialContext.lookup(InitialContext.java:396)
        at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:129)
        ... 11 more
je vois pourquoi il ne detecte pas la base de données dbvol malgré que je l'ai configuré lors de la creation de l'unité de persistence
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
<?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="OACA-ejbPU" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>voldb</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
    </properties>
  </persistence-unit>
</persistence>
quelqu'un peut m'aider je suis coincé il ya 3 jours et je trouve pas de solution
et il ne me reste plus de temps
merci d'avance