Hallo, ich habe das Problem, dass ich keinen Zugriff auf den EJB-Container erreichen kann. Das EJB-Modul befindet sich auf dem glassfishv2.1 webserver welcher local installiert ist. Ich versuche den Zugriff über einen lookup zu realisieren, dazu verwende ich folgende code im Applikation-Client:

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
public class run {
 
    /**
     * @param args
     */
    @EJB 
    public static BeanRemote ebr;
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        int Schleifenindex=1;
        
        String Befehl;
        
        try {
    
            
            [B]InitialContext context = new InitialContext();
            ebr= (BeanRemote) context.lookup(BeanRemote.class.getName());
            System.out.println("das hat funktioeniert"+context.lookup(BeanRemote.class.getName())); [/B]
                    
            while (Schleifenindex !=0){
 
                 Scanner BEFEHL = new Scanner(System.in);
                 System.out.println("Geben Sie einen Befehl ein:");
                 Befehl=BEFEHL.nextLine();
                 char char_befehl=Befehl.charAt(0);
 
                    switch (char_befehl){
                         case 't':System.out.println(ebr.getTest());                        
                            break;
                         case 'e': Schleifenindex=0;
                            break;
                         case 's':ebr.setName();                            
                            break;
                         case 'g':ebr.getName();                            
                            break;
                    }
             }
                    
            System.out.println(ebr.getTest());
        } catch (NamingException e) {
            e.printStackTrace();
        }
        
    }
 
}

Der Zugriff hatte vorher funktioniert aber irgendetwas muss ich wohl falsch koniguriert haben.

Folgende Exception wird ausgegeben

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
javax.naming.NamingException: Lookup failed for 'org.ejb.stateful.BeanRemote' in SerialContext ,orb'sInitialHost=localhost,orb'sInitialPort=3700 [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext ,orb'sInitialHost=localhost,orb'sInitialPort=3700 [Root exception is java.lang.ClassCastException]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:434)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at src.client.main.run.main(run.java:38)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext ,orb'sInitialHost=localhost,orb'sInitialPort=3700 [Root exception is java.lang.ClassCastException]
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:266)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:420)
    ... 2 more
Caused by: java.lang.ClassCastException
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:258)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    at com.sun.enterprise.naming.impl.SerialContext.narrowProvider(SerialContext.java:349)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:317)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:262)
    ... 3 more
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.enterprise.naming.impl.SerialContextProvider
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:250)
    ... 7 more


Bitte um Hilfe!