Help! LocalHome Interface ClassCastException

Hi All, I am new to EJBs..

I am trying to call my remote/local Entity Bean in a servlet.

InitialContext jndiContext = new InitialContext();

Object ref = jndiContext.lookup("POrderMasterRemote");

//Object ref = jndiContext.lookup("POrderMaster"); <-- LocalHome - Line:X

System.out.println(ref.toString());

POrder.POrderMasterRemoteHome home = (POrder.POrderMasterRemoteHome)PortableRemoteObject.narrow(ref,POrder.POrderMasterRemoteHome.class); // success

//POrder.POrderMasterHome home = (POrder.POrderMasterHome)ref; <-- CastException - Line:Y

I can call my Entity Beans's RemoteHome inteface and cast it correctly, but i can not cast LocalHome interface. I am sure that i got something after Line:X.

This is System.out:

POrder.POrderMasterBean_93z9b4_LocalHomeImpl@17675

But Line:Y has ClassCastException:

java.lang.ClassCastException: POrder.POrderMasterBean_93z9b4_LocalHomeImpl

...

Could you tell me whats wrong? Thank you ~

[1026 byte] By [Milliard] at [2007-9-27 20:42:37]
# 1
Hi,Are you using different sets of interfaces and deployment descriptors for each type of access (do you have both remote and local interface)?
adibaron at 2007-7-7 2:02:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

> Hi,

>

> Are you using different sets of interfaces and

> deployment descriptors for each type of access (do you

> have both remote and local interface)?

Yes. I have both remote and local interface.

And yesterday afternoon(GMT+8 Taipei), I try to use a session bean to call and cast my entity bean's LocalHome interface .

(JSP --> Servlet --> Session Bean --> Entity Bean)

It's work! My program run correctly and I got result as expect. I don't understand why. Is that Bean's LocalHome Interface can be used by another program in the server side only?

Thank you ~ :)

Milliard at 2007-7-7 2:02:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Hi Again,Local references can be used only by objects that "live" within the same virtual machine...A client that is executed outside cannot use local EJBs
adibaron at 2007-7-7 2:02:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

> Hi Again,

>

> Local references can be used only by objects that

> "live" within the same virtual machine...

> A client that is executed outside cannot use local

> EJBs

Thanks adibaron.

Thank you for you exposition of EJB's LocalHome interface. :)

Milliard at 2007-7-7 2:02:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...