This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassCastException...??????  RSS feed

manju latha
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam working with sample stateful session bean
can any body please reply me what could be the problem here in my client code below.
Properties prop = new Properties();
prop.put(Context.SECURITY_PRINCIPAL, "venu");
prop.put(Context.SECURITY_CREDENTIALS, "venuvenu");
Context ctx = new InitialContext(prop);
Object obj = ctx.lookup("banking");
banksfullHome home = (banksfullHome)PortableRemoteObject.narrow(obj,banksfullHome.class);
banksfullRemote br1 = (banksfullRemote)PortableRemoteObject.narrow(home.create(999),banksfullRemote.class);
banksfullRemote br2 = (banksfullRemote)PortableRemoteObject.narrow(home.create(888,"Shiva",3000.00),banksfullRemote.class);


and my Home is
public interface banksfullHome extends EJBHome
public banksfullRemote create(int accNo) throws RemoteException,CreateException;
public banksfullRemote create(int accNo,String accName,double bal)throws RemoteException,CreateException;

iam getting ClassCastException when running client as:
java.lang.ClassCastException at Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by manju latha:

You only need to cast (narrow) the references returned by the naming service - i.e. the home interface in your example. When creating the remote beans, you should only need to do this...

Let us know how you get on...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!