Newsgroup: it.comp.java
Titolo: RMI under Linux: rmiregistry - ...java.net.SocketException: Connection reset

Under Red Hat Linux 8.0 my RMI server application, when I try to bind :
...
/* Bind RMI */
    RMIExperimentImpl rmiExperimentImpl = new RMIExperimentImpl(es);
    Naming.rebind("rmi://localhost" + ":" + port + "/experiment",
rmiExperimentImpl);
}
    catch (RemoteException re) {
      System.out.println("Exception in ExperimentServer: " + re);
    }
...
It catch the following RemoteException:
"java.rmi.UnmarshalException: Error unmarshaling return header;
nested exception is: java.net.SocketException: Connection reset".
And it works under Windows 2000 without any problem.
Any ideas?
Many thanks,
Ales.

Alex wrote:

I am no expert on this, but...
Did you build the client and server for the same target release of Java? If 
not, the RMI objects may be serialized differently and I believe it can 
result in this type of error.
-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    
n...@ion.le.ac.uk
 
Phone :     
+44 (0)116 2523548
, Fax : 
+44 (0)116 2523555

I have similar errors under Linux 7.2 while my RMI server application 
works well under Win 2000.
To get rid of the Marshaling error, I added the following line in the 
policy.txt:
grant
  {
     permission java.net.SocketPermission.AllPermission;
     permission java.security.AllPermission;
  }
Have you set a policy.txt file?
Now, the error I get is the following:
HelloApplet exception: access denied (java.net.SocketPermission 
192.168.33.3:1099
 connect,resolve) java.security.AccessControlException: 
access denied(java.net.SocketPermission 
192.168.33.3:1099
 connect,resolve)
I am testing a few other things, but truely, RMI is getting a bit on my 
nerves....
Joffrey


Ok, I got my server application to work, (actually I still have a bug; 
the client application only works locally).
To recap:
1)  started the rmiregistry:   nohup rmiregistry &
2)  launched the server application:
nohup java -Djava.rmi.server.hostname=192.168.33.3 
-Djava.rmi.server.logCalls
=true -Djava.rmi.server.codebase=file:///root/java/ 
-Djava.security.manager -Djava.security.policy=/root/java/policy.txt 
examples.hello.HelloImpl 2>&1 > sHello.out &
policy.txt contains the following:
grant {
         permission java.net.SocketPermission "*","connect";
         permission java.net.SocketPermission "*","accept";
         permission java.net.SocketPermission "*","resolve";
         permission java.net.SocketPermission.AllPermission;
         permission java.security.AllPermission;
         };
note:  I know I am giving away too many permissions - but hey, while 
troubleshooting, more is better.
3)  launched the client application:
appletviewer Hello.html
Hello.html contains the following:
         <HTML>
         <title>Hello World</title>
         <center> <h1>Hello World</h1> </center>
         <applet codebase="/root/java/"
                 code="examples.hello.HelloApplet"
                 width=500 height=120>
         </applet>
         </HTML>
The code I use was from the examples given in the RMI tutorial on Sun's 
web site : 
http://java.sun.com/products/jdk/rmi/
Ok, so this works but when I try to launch the appletviewer on my Win 
2000 to access my linux box, I get the following error:
HelloApplet exception: access denied (java.net.SocketPermission 
192.168.33.3:1099
 connect,resolve) java.security.AccessControlException: 
access denied (java.net.SocketPermission 
192.168.33.3:1099
 connect,resolve)
There is something (probably a permission) that prevents an external box 
from accessing the server application.
If you have any idea, please let me know.
Joffrey


Joffrey Bienvenue wrote:

It's an applet permission problem. Applets are only allowed to open sockets 
to the host from which they were downloaded. In the case of appletviewer, 
the applet is effectively "downloaded" from localhost so it can only open 
sockets to the localhost.
You either need to run a Web server on the same host as the RMI server to 
serve the applet to clients, or you need to sign the applet.


I'had the same problem... after setting permissions on
java.policy file (you can find it inside SDK\jre\security\)
Virual Machine need to be started from SDK directory
instead using the PATH instruction to start it from another
place.