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

RemoteException not reporting propert stack trace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • x86
    • windows_95



      Name: rm29839 Date: 05/28/98


      I have created an example that illustrates the problem
      in the following classes. Basically, I created an RMI
      server that starts and registers a UnicastRemoteObject.
      The Object throws a NullPointerException exception when
      any of the methods are called. Next I created a client
      which binds to the RemoteObject and calls one of the
      methods. Naturally a RemoteException with a nested
      NullPointerException is thrown, however, the stack trace
      on the RemoteException does not report the client code
      line that the exception was generated from. If I try
      to fill in the stack trace on the client I get an invalid
      trace which does not reflect the client code line that
      failed. Example classes follow.


      import java.rmi.*;
      import java.rmi.server.*;

      public class RemoteStatus extends UnicastRemoteObject implements iStatus
      {

          /**
           * Constructor.
           */
          public RemoteStatus ()
      throws RemoteException
          {
          }

          public void f2()
      throws RemoteException
          {
      f3();
          }
          
          public void f3()
      throws RemoteException
          {
      f4();
          }
          
          public void f4()
      throws RemoteException
          {
      f5();
          }
          
          public void f5()
      throws RemoteException
          {
      f6();
          }
          
          public void f6()
      throws RemoteException
          {
      try
      {
      f7();
      }
      catch (Exception e)
      {
      RemoteException re = new RemoteException("Exception in f7");
      re.detail = e;
      throw re;
      }
          }
          
          public void f7()
          {
      f8();
          }
          
          public void f8()
          {
      String npe = null;
      char[] chars = npe.toCharArray();
          }
      }


      import java.rmi.*;
      import java.rmi.registry.*;

      public class StatusServer
      {

          /**
           * Constructor.
           */
          public StatusServer ()
          {
          }

          public static void main(String args[])
          {
      //Generate a Remote class
      //
      try
      {
      System.setSecurityManager(new RMISecurityManager());
      System.getProperties().put("java.rmi.server.codebase",
      "http://intranet.tridsys.com/~stoddard/");

      System.out.println("Creating Server Object");
      RemoteStatus status = new RemoteStatus();
      LocateRegistry.createRegistry(1099);
      System.out.println("Binding RemoteStatus");
      Naming.rebind("RemoteStatus", status);
      System.out.println("Server is ready");
      }
      catch (Exception e)
      {
      e.printStackTrace(System.out);
      }
          }
      }


      import java.rmi.*;

      public class StatusTest
      {
          static iStatus status;
          static RemoteStatus remoteStatus;

          /**
           * Constructor.
           */
          public StatusTest ()
          {
          }

          public static void main(String args[])
          {
      try
      {
      System.setSecurityManager(new RMISecurityManager());

      status = (iStatus)Naming.lookup(
      "rmi://192.168.1.133:1099/RemoteStatus");

      System.out.println("Server found");

      remoteStatus = new RemoteStatus();

      //Generate a NullPointerException
      //
      f1();
      }
      catch (Exception e)
      {
      e.printStackTrace(System.out);
      }
      finally
      {
      System.exit(0);
      }
          }

          
          public static void f1()
          {
      try
      {
      status.f2();
      }
      catch (RemoteException e)
      {
      e.fillInStackTrace();
      e.printStackTrace(System.out);
      }

      try
      {
      remoteStatus.f8();
      }
      catch (Exception e)
      {
      e.fillInStackTrace();
      e.printStackTrace(System.out);
      }
          }
      }


      import java.rmi.*;

      public interface iStatus extends Remote
      {
          public void f2() throws RemoteException;
          public void f3() throws RemoteException;
          public void f4() throws RemoteException;
          public void f5() throws RemoteException;
          public void f6() throws RemoteException;
      }

      When I run the example I get the following output

      Server found
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
              java.rmi.RemoteException: Exception in f7; nested exception is:
              java.lang.NullPointerException:
              at StatusTest.f1(StatusTest.java:51)
              at StatusTest.main(StatusTest.java:30)
      java.lang.NullPointerException
              at StatusTest.f1(StatusTest.java:61)
              at StatusTest.main(StatusTest.java:30)

      At no time does the stack trace report an exception at
      line StatusTest.java:47 or StatusTest.java:57, which are
      the lines in the try blocks.
      (Review ID: 30715)
      ======================================================================

            ldorninsunw Laird Dornin (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: