3 Replies Latest reply: Feb 14, 2011 7:15 PM by EJP RSS

    UnmarshalException trying to follow "1st steps in activation" tutorial

    829050
      Hi,

      I am following the Oracle first steps tutorial in rmi activation here:

      - http://download.oracle.com/javase/1.4.2/docs/guide/rmi/activation/activation.1.html

      These are some very simple classes and interface etc. which will no doubt take an experienced activationist less than a minute to absorb if they can spare the time...

      I had a first difficulty with the security policy not allowing Step 5 here "Run the setup program" to run... I then commented out the line
      props.put("java.security.policy", "D:\\policy");
      in Setup.java (NB this is indeed where I have put the "allow everything" file called "policy" which comes with the .zip file here)
      I'd like in the future to understand what went wrong there... but :

      I was then happy to see that step 5 ran OK with the expected output.

      When I ran step 6, however, I am getting an "UnmarshalException" with the following trace

      java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
      java.io.EOFException
      at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
      at sun.rmi.server.UnicastRef.invoke(Unknown Source)
      at sun.rmi.server.ActivatableRef.invoke(Unknown Source)
      at examples.activation.ActivatableImplementation_Stub.callMeRemotely(Unknown Source)
      at examples.activation.Client.main(Client.java:53)
      Caused by: java.io.EOFException
      at java.io.DataInputStream.readByte(Unknown Source)

      ... obviously the method used here is as simple as simple can be
      public Object callMeRemotely() throws RemoteException {
                return "Success";
      }
      Naturally I have tried various tweaks to see if this can be overcome... to no avail.

      Can anyone shed any light on this?

      Thanks
      Mike
        • 1. Re: UnmarshalException trying to follow "1st steps in activation" tutorial
          EJP
          Activation is tough, badly designed (see all the deprecated ctors & methods in Activatable, and also the complete lack of any way to talk SSL to the ActivationSystem), and poorly documented. Can I seriously recommend you get hold of a copy of my book java.rmi: The Guide to Remote Method Invocation. Available 2nd-hand all over the place. This is where I analyzed all the pointless ctors & methods that were subsequently deprecated.

          You should be looking at the current version of the tutorial, not the ancient 1.4 version. However all versions are wrong about one thing. In step 5, where you get the activatable stub, you must serialize it into a file. Otherwise it gets lost next time you have to start the registry. Then you need to add a startup program which reads the stub out of that file and binds it into the Regsitry. The setup program gets executed exactly once; the startup program gets executed once per system startup. If you do it the way the tutorial suggests, you have to run the setup program once per system startup, which continually re-registers new instances of the same ActivationDesc, which is just a waste of time and space (in rmid.log). Entirely pointless.

          Having said all that, I can't see anything wrong with what you're doing that would cause the EOFException. It might come down to something nasty like GNU CLASSPATH's so-called version of Java, which if present should be eradicated from your system forthwith. Check java -version, registry -version, rmid -version, etc in all the places you are running them from, and ensure they all refer to a Sun JDK/JRE of the expected version.

          You should also run rmid with -J-Djava.rmi.server.logCalls=true. If this doesn't disclose anything interesting, try setting sun.rmi.server.exceptionTrace=true in the same way, and then if it gets really hairy we may have to enable some of the transport logging, in both rmid and your client. See http://download.oracle.com/javase/6/docs/technotes/guides/rmi/javarmiproperties.html and http://download.oracle.com/javase/6/docs/technotes/guides/rmi/sunrmiproperties.html.
          • 2. Re: UnmarshalException trying to follow "1st steps in activation" tutorial
            829050
            thanks.
            EJP wrote:
            Activation is tough, badly designed (see all the deprecated ctors & methods in Activatable, and also the complete lack of any way to talk SSL to the ActivationSystem), and poorly documented. Can I seriously recommend you get hold of a copy of my book java.rmi: The Guide to Remote Method Invocation. Available 2nd-hand all over the place. This is where I analyzed all the pointless ctors & methods that were subsequently deprecated.
            I love stuffing my bookshelves full of techy books which visitors can't make head or tail of ... and Java Concurrency in Practice was truly fascinating, and daunting. I shall order your book forthwith.

            >
            You should be looking at the current version of the tutorial, not the ancient 1.4 version.
            thanks... the 1.4 version was the one I landed at by googling. I probably tried searching the Oracle site too.
            However all versions are wrong about one thing. In step 5, where you get the activatable stub, you must serialize it into a file. Otherwise it gets lost next time you have to start the registry. Then you need to add a startup program which reads the stub out of that file and binds it into the Regsitry. The setup program gets executed exactly once; the startup program gets executed once per system startup. If you do it the way the tutorial suggests, you have to run the setup program once per system startup, which continually re-registers new instances of the same ActivationDesc, which is just a waste of time and space (in rmid.log). Entirely pointless.
            Understood.
            >
            Having said all that, I can't see anything wrong with what you're doing that would cause the EOFException. It might come down to something nasty like GNU CLASSPATH's so-called version of Java, which if present should be eradicated from your system forthwith. Check java -version, registry -version, rmid -version, etc in all the places you are running them from, and ensure they all refer to a Sun JDK/JRE of the expected version.
            I've got
            java version "1.6.0_23-ea"
            Java(TM) SE Runtime Environment (build 1.6.0_23-ea-b01)
            OpenJDK Client VM (build 19.0-b06, mixed mode, sharing)
            ... which is a surprise to me - I thought I had the Sun JDK. But, from a quick glimpse at Wikipedia, OpenJDK does not seem to be the same as "GNU CLASSPATH". Will get hold of the Sun JDK/JRE.
            I'm not too sure how to get the registry and rmid versions, but I'm sure I'll figure it out.

            >
            You should also run rmid with -J-Djava.rmi.server.logCalls=true. If this doesn't disclose anything interesting, try setting sun.rmi.server.exceptionTrace=true in the same way, and then if it gets really hairy we may have to enable some of the transport logging, in both rmid and your client. See http://download.oracle.com/javase/6/docs/technotes/guides/rmi/javarmiproperties.html and http://download.oracle.com/javase/6/docs/technotes/guides/rmi/sunrmiproperties.html.
            OK, thanks for the info.

            If you remember my previous thread of a few days ago, my idea of registering (binding) a few dummy keys (locks, if you will) when I set up the rmiregistry programmatically in fact seems to be an OK workaround when you don't know which of potentially simultaneous Processes is going to start the server running, at least until I can get to grips with activation.

            As a reminder, this is about using Java to handle OpenOffice events... and the first inter-Process requirement is a multi-Process logger (strictly speaking it's the same Process... the soffice.bin Process... although each Thread you're given appears to be an event-thread which freezes all OOo GUI, so for non-trivial stuff you have to spawn new Processes).
            • 3. Re: UnmarshalException trying to follow "1st steps in activation" tutorial
              EJP
              It sounds like your activation-group JVM is exiting prematurely. Probably something wrong with the ActivationDesc or ActivationGroupDesc. It would be really useful to run rmid -J-Dsun.rmi.server.exceptionTrace=true, and also to set that property to that value in the ActivationGroupDesc when you register the ActivationGroup so it is propagated to the activation-group JVM. Same for the other property I mentioned. You could also set java.security.debug=access,failure in the rmid command line and the activation group properties too.