• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Going crazy casting local home interface

 
Walter Chen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34667
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic