JAV2I 1.2 NO IDEA Avatar
  1. OMG Issue

JAV2I12 — Issue with using the local stub with for example an EJB application

  • Key: JAV2I12-5
  • Legacy Issue Number: 4429
  • Status: closed  
  • Source: Anonymous
  • Summary:

    When using the local stub with for example an EJB application, we discovered the following critical issue.

    Let's take an simple example :

    public interface HelloWorld extends javax.rmi.EJBObject

    { void print( String message ); }

    The generated Stub according to the mapping rules contains the methods for the inherited interface as for example 'getEJBHome'.

    For a local invocation on 'getEJBHome' the following part of the stub will be used :

    public javax.ejb.EJBHome getEJBHome() throws java.rmi.RemoteException { while( true ) { if (!javax.rmi.CORBA.Util.isLocal(this) )

    { // non local use }

    else { org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("EJBHome", HelloWorld.class);

    if ( _so == null ) return getEJBHome();

    try

    {return ((javax.ejb.EJBObject)_so.servant).getEJBHome(); }

    catch ( Throwable ex )

    { Throwable ex2 = ( Throwable ) javax.rmi.CORBA.Util.copyObject(ex, _orb()); throw javax.rmi.CORBA.Util.wrapException(ex2); }

    finally {_servant_postinvoke(_so); } } } }

    The '_servant_preinvoke' method will return a servant class of type 'HelloWorld' that implements the 'getEJBHome' operation.

    Thus, the '_HelloWorld_Tie' servant is returned.

    Then, the cast to convert the returned servant to 'javax.ejb.EJBObject' will fail since the servant doesn't implement this interface ( it only inherits from org.omg.PortableServer.Servant and implements javax.rmi.CORBA.Tie ).

    Thus, by using the local stub, it is not possible to invoke an inherited operation.

    Solution :

    The returned servant is always implementing 'javax.rmi.CORBA.Tie'. To allow the correct cast to 'javax.ejb.EJBObject' we need to access the final target instead of the servant itself. So the following solution can be always applied :

    javax.rmi.CORBA.Tie tie = ((javax.rmi.CORBA.Tie)_so.servant);

    return ((javax.ejb.EJBObject)tie.getTarget()).getEJBHome();

  • Reported: JAV2I 1.1 — Wed, 25 Jul 2001 04:00 GMT
  • Disposition: Resolved — JAV2I 1.2
  • Disposition Summary:

    Closed, accepted. See revised text below.

  • Updated: Fri, 6 Mar 2015 20:58 GMT