Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassCastException...??????

 
manju latha
Greenhorn
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.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://localhost:7001");
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);

System.out.println(br1.getBalance());
System.out.println(br2.getBalance());

.................
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 com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • 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...
Simon
 
brevity is the soul of wit - shakepeare. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!