i am surprised because i have two ejb on two deifferent server which are communicating together via remote interface and i do not need to use javax.rmi.PortableRemoteObject.narrow to cast the stub after the looking method I can directly doing that:. ( MyRemoteHome) initial.lookup ( "ejb / nameOfMyEjb");. Idem with ever java client connecting to the server and using the remote EJB i do not understand because every documents i read explain that it's necessary to use PortableRemoteObject to cast the stub. But it's seem to be not necessary when the remote object is a java object. I WOUL Be Very Happy To Know Your Point of View About That. Thank you very much
In most of the casses, the EJBs are remotley exposed through RMI. You can have JRMP RMI and IIOP RMI. For IIOP RMI you need to do the narrowing that marshalls the IDLs (used by the IIOP) to / from java classes. JRMP RMI .
Most native Java RMI protocols (JRMP and protocols specifically designed by application servers) make use of Java's dynamic class loading to load the stub of the correct runtime type at runtime, so you can do normal casting. Protocols like IIOP that are designed to support systems with no dynamic class loading do not support this feature. So when an IIOP remote stub is returned it does not have the correct runtime type to begin with. you have to explicitly cast it to the type of stub you want. Because EJB is designed to support IIOP (as well as JRMP and such native protocols) you have to use PortableRemoteObject.narrow if you want your code to be compliant. If you do not, then if you move to some other application server your application may stop workingIn both scenarios you described both JRMP and IIOP (as well as other protocols) can be used by the server for communication. It is up to the server to decide which protocol to use. Whether you make calls from within a server of from a J2 EE client, you use the stubs generated by the server. These stubs implement whatever protocol the server wants to use. In addition, EJB servers must be capable of supporting IIOP requests (even if the server uses JRMP for normal communication) so that EJBs can Be Invoked by Non-Java Clients Using Corba.
i have read documentation about rmic compiler. If the option -iiop is chosen then stub using iiop are generated and remote proxy are no more skeleton class but tie class (http://java.sun.com/j2se/1.4.2/docs /Guide/rmi-iiop/rmi_iiop_pg.html). Sun ONE Application Server Uses-IIOP Options. So How Can I Cast Withuan Javax.rmi.PortableRemoteObject.narrow Even Iiop Seems To BE Used? Thank a Lot