Bonjour,
J'ai créé un simple EJB Module et un stateless EJB avec netbeans7.2.1 et glassfish3. Je veut créer un test qui fait appel à cet EJB.

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
public class MyEJBTest {
 
    MyEJBLocal myEJB;
    Context ctx;
 
    public MyEJBTest() throws NamingException {
        Properties props = new Properties();
  props.setProperty("java.naming.factory.initial",
                    "com.sun.enterprise.naming.SerialInitContextFactory");
  props.setProperty("java.naming.factory.url.pkgs",
                    "com.sun.enterprise.naming");
  props.setProperty("java.naming.factory.state",
                    "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        ctx = new InitialContext(props);
        myEJB = (MyEJBLocal) ctx.lookup("java:module/MyEJB");
    }
    @Test
    public void testSayHello() throws Exception {
        assertNotNull(myEJB);
        assertEquals("hello", myEJB.sayHello());
    }
Quand je lance le test, j'ai le message suivant. Je ne sais pas quoi faire pour le corriger.
Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory