Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4419156

cannot invoke method over RMI/IIOP: its name clashes with an IDL keyword

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • other-libs
    • beta2
    • generic
    • generic
    • Not verified



        Name: boT120536 Date: 02/26/2001


        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
        Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

        Given an RMI server with a remote interface which has methods that clash with
        IDL keywords. When a client invokes on these method a CORBA UNKNOWN exception
        is raised by the server:

        Invocation failed : java.rmi.RemoteException: CORBA UNKNOWN 1398079491 No;
        nested exception is:
                org.omg.CORBA.UNKNOWN: minor code: 1398079491 completed: No


        The exact came code works without problem if RMI/JRMP is used. These methods
        should be allowable according to the Java to IDL mapping.



        The interface;

        public interface KeyWords extends Remote
        {
            final static String JNDI_NAME="test.keywords";

            void module() throws RemoteException;
            void typedef() throws RemoteException;
            void unsigned() throws RemoteException;
            void wchar() throws RemoteException;
            void octet() throws RemoteException;
            void any() throws RemoteException;
            void object() throws RemoteException;
            void fixed() throws RemoteException;
            void struct() throws RemoteException;
            void union() throws RemoteException;
            void enum() throws RemoteException;
            void sequence() throws RemoteException;
            void string() throws RemoteException;
            void wstring() throws RemoteException;
            void exception() throws RemoteException;
            void readonly() throws RemoteException;
            void attribute() throws RemoteException;
            void oneway() throws RemoteException;
            void idempotent() throws RemoteException;
            void in() throws RemoteException;
            void out() throws RemoteException;
            void inout() throws RemoteException;
            void raises() throws RemoteException;
            void context() throws RemoteException;
            void valuebase() throws RemoteException;
            void value() throws RemoteException;
            void truncatable() throws RemoteException;
            void custom() throws RemoteException;
            void local() throws RemoteException;
            void supports() throws RemoteException;
        }

        with implementation

        import java.rmi.Remote;
        import java.rmi.RemoteException;
        import java.util.Vector;

        import java.rmi.Naming;

        import javax.rmi.PortableRemoteObject;
        import java.net.MalformedURLException;
        import java.util.Hashtable;
        import javax.naming.Context;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;


        /** implementation of KeyWords interface
         */
        public class KeyWordsImpl extends PortableRemoteObject implements KeyWords
        {
          public static void main(String[] args)
          {
            try {
              KeyWords srv = new KeyWordsImpl();

                Hashtable environment = new Hashtable();
                environment.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
                environment.put(Context.PROVIDER_URL, "iiop://localhost:2020");
                Context ctx = new InitialContext(environment);

                System.out.println("Server registering servant in registry");
                try {
           ctx.bind(JNDI_NAME,srv);
                } catch(NamingException ex) {
           try {
           ctx.rebind(JNDI_NAME, srv);
           } catch(NamingException ne) {
           System.out.println("failed to register object in JNDI" );
           }
                }
            } catch(RemoteException ex) {
              System.out.println("Remote exception in server: " + ex.toString());
              ex.printStackTrace();
            } catch(Exception ex) {
        System.out.println("Exception : " + ex.toString());
            }
          }


          public KeyWordsImpl() throws RemoteException {}
          public void module() {}
          public void typedef() {}
          public void unsigned() {}
          public void wchar() {}
          public void octet() {}
          public void any() {}
          public void object() {}
          public void fixed() {}
          public void struct() {}
          public void union() {}
          public void enum() {}
          public void sequence() {}
          public void string() {}
          public void wstring() {}
          public void exception() {}
          public void readonly() {}
          public void attribute() {}
          public void oneway() {}
          public void idempotent() {}
          public void in() {}
          public void out() {}
          public void inout() {}
          public void raises() {}
          public void context() {}
          public void valuebase() {}
          public void value() {}
          public void truncatable() {}
          public void custom() {}
          public void local() {}
          public void supports() {}
        }


        The Client:

        import java.util.Hashtable;
        import javax.naming.InitialContext;
        import javax.naming.Context;
        import javax.rmi.PortableRemoteObject;
        import javax.naming.NamingException;
        import java.rmi.RemoteException;
        import java.lang.reflect.Method;
        import java.lang.reflect.InvocationTargetException;
        import java.rmi.Naming;

        public class Client
        {
          public static void main(String[] args)
          {
              Hashtable environment = new Hashtable();
              environment.put(Context.INITIAL_CONTEXT_FACTORY,
        "com.sun.jndi.cosnaming.CNCtxFactory");
              environment.put(Context.PROVIDER_URL, "iiop://localhost:2020");

              try {
                  Context ctx = new InitialContext(environment);
                  KeyWords srv =
        (KeyWords)PortableRemoteObject.narrow(ctx.lookup(KeyWords.JNDI_NAME),
        KeyWords.class);

                Method[] methods = KeyWords.class.getMethods();

                for(int i=0; i<methods.length; i++) {
                    try {
                        System.out.println("invoking method " + methods[i].getName());
                        methods[i].invoke(srv, new Object[] {});
                        System.out.println("succeeded in invoking method " +methods[i].getName());
                    } catch(InvocationTargetException ite) {
                        System.out.println("Invocation failed : " +ite.getTargetException().toString());
                    } catch(Exception ex) {
                        System.out.println("Invocation failed : " + ex.toString());
                    }
                }
              } catch(Exception ex) {
                System.out.println("failed to find object " + KeyWords.JNDI_NAME + " in JNDI: "+ ex.toString());
              }
          }
        }


          To build:

        javac *.java
        rmic -iiop KeyWordsImpl

        Before running, make sure that the tnameserv process is running and listening on
        port 2020 (or change the code).
        (Review ID: 115220)
        ======================================================================

              sbauersunw Stefan Bauer (Inactive)
              bonealsunw Bret O'neal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: