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:
Der Zugriff hatte vorher funktioniert aber irgendetwas muss ich wohl falsch koniguriert haben.
Folgende Exception wird ausgegeben
Bitte um Hilfe!
Code:
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 {
InitialContext context = new InitialContext();
ebr= (BeanRemote) context.lookup(BeanRemote.class.getName());
System.out.println("das hat funktioeniert"+context.lookup(BeanRemote.class.getName()));
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:
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!