File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCastException by PortableRemoteObject.narrow

 
Matthias Roselieb
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic