• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Going crazy casting local home interface

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is weird! Say I have a session bean with a local home and local interfaces. From the client, I could get the local home interface by JNDI look-up, this is my code:

Object obj = initial.lookup("java:comp/env/ejb/MySessionLocal");
System.out.println("Looked up local home, class is: " + obj.getClass());

The System.out prints out something like the following:

Looked up local home, class is: ejbs.EJSLocalMySessionHome_5c39c28d

So, ejbs.EJSLocalMySessionHome_5c39c28d is the stub. I looked at the code inside this file, it has the following:

public class EJSLocalMySessionHome_5c39c28d extends EJSLocalWrapper implements ejbs.MySessionLocalHome {

public EJSLocalMySessionHome_5c39c28d() {
super();}

So far so good. It is clear that this stub implements the local home interface ejbs.MySessionLocalHome


However, in my client code, when I do the following:

ejbs.MySessionLocalHome mySessionHomeIf = (ejbs.MySessionLocalHome) obj;

I get a ClassCastException. How can this be? It DOES implement the home interface, why can't I cast it???

Thanks in advance.
Walter
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Walter,
Often that has to do with bad deployed code or different JVMs. Since you are using a client, it is probably different JVMs.

What kind of client is this? Usually a client cannot make local EJB calls.
 
Walter Chen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client and server are running on the same server inside the same JVM, I am using Websphere 6.0, I will check the VM tomorrow, but I believe it is IBM's standard VM.

Thanks,
Walter
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic