users@glassfish.java.net

Exposing EJB2 as EJB3?

From: <glassfish_at_javadesktop.org>
Date: Tue, 11 Nov 2008 10:41:46 PST

Hi all,

I am very confused about an application that I have not developed but have to maintain now.

The application has an EJB that is implementing the EJB2.1 interfaces:

Remote interface:

public interface ServerComponent extends EJBObject {...

Home interface:

public interface ServerComponentHome extends EJBHome {..

Bean:

public class ServerComponentBean implements SessionBean {

So far so good. BUT!! In the calling component of the application the EJB is looked up like this:

ServerComponentHome home = (ServerComponentHome)ctx.lookup("ServerComponentHomeJNDI");
ServerComponent secTest = (ServerComponent)PortableRemoteObject.narrow(home.create(),
                ServerComponent.class);

As you see the first line of the calling code is not using PortableRemoteObject.narrow, which is mandatory when looking up EJB2.1 beans and can only be omitted when calling EJB3 beans. This is according to the documentation i found concerning this topic. But surprisingly the lookup succeds and I would like to know why.

Can anyone enlighten me on this?

Thanks,
Chris
[Message sent by forum member 'candlejack' (candlejack)]

http://forums.java.net/jive/thread.jspa?messageID=316077