• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

ClassCastException...??????

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic