jQuery in Action, 2nd edition*
The moose likes Websphere and the fly likes ClassCastException by  PortableRemoteObject.narrow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "ClassCastException by  PortableRemoteObject.narrow" Watch "ClassCastException by  PortableRemoteObject.narrow" New topic
Author

ClassCastException by PortableRemoteObject.narrow

Matthias Roselieb
Greenhorn

Joined: Aug 09, 2005
Posts: 1
Hi,
I have to create a sample client for IBM Websphere 6.


At the last line the following exception is thrown:



Can anybody help me?


thx
Matthias

[ August 09, 2005: Message edited by: Matthias Roselieb ]
[ August 09, 2005: Message edited by: Matthias Roselieb ]
Lars Vonk
Ranch Hand

Joined: Aug 05, 2005
Posts: 30
Matthias,

Check the following:
Did you generate your stubs and ties?
If so did you put them in the classpath?

Also I have some questions about your code:

Context ctx = new InitialContext(env);
Object obj = ctx.lookup("WSsamples/BasicCalculator");
BasicCalculatorHome home=(BasicCalculatorHome)ctx.lookup("WSsamples/BasicCalculator");
PortableRemoteObject port=new PortableRemoteObject();
BasicCalculatorHome home = (BasicCalculatorHome) port.narrow((org.omg.CORBA.Object)obj, BasicCalculatorHome.class);

Why do you look up your BasicCalculator twice? In my believe the line: "BasicCalculatorHome home=(BasicCalculatorHome)ctx.lookup("WSsamples/BasicCalculator");" will not work since the home is not put in JNDI as a Home Interface, so you cannot cast it. I think your code should look like this:

Context ctx = new InitialContext(env);
Object obj = ctx.lookup("WSsamples/BasicCalculator");
BasicCalculatorHome home = (BasicCalculatorHome) PortableRemoteObject.narrow(obj, BasicCalculatorHome.class);
MyComponentInterface myCompIface = home.create();

Good luck,
Lars
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ClassCastException by PortableRemoteObject.narrow
 
Similar Threads
calling a EJB from JSP in weblogic , please help me fast
InitialContext lookup
Exception accessing Local EJB
Standalone Java EJB client
WebSphere 5