Hi,
This problem occured to me while running the client code (HeadFirst
EJB page 57)
after successful deployment of Advice EJB.
C:\EJB\projects\advice>
java -cp .;c:\EJB\projects\AdviceAppClient.jar;D:\j2sdkee
1.3.1\lib\j2ee.jar;C:\EJB\projects\advice\classes AdviceClient
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Porta
bleRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at AdviceClient.go(AdviceClient.java:15)
at AdviceClient.main(AdviceClient.java:9)
I used following code for client (given on HFE page 57) :
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient {
public static void main(
String [] args) {
new AdviceClient().go();
}
public void go() {
try {
Context ic = new InitialContext();
Object o = ic.lookup("Advisor");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println(advisor.getAdvice());
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
I am using following versions of JSDK and J2SDKEE: j2sdk1.4.0 and j2sdkee1.3.1
Looking forward to help,
rajesh -
SCJP (1.4)