Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help with rmi

7 views
Skip to first unread message

Cyril Bérion

unread,
Feb 4, 2002, 5:18:56 AM2/4/02
to
Hello, i'm trying to work with RMI, but i can't start the server,
here is a description of the problem:

# I use a few simple files :
[cyril@cyril echo]$ ls
EchoAppliServer.class EchoClient.class EchoImpl.java Echo.java
EchoAppliServer.java EchoClient.java EchoImpl_Skel.class
Echo.class EchoImpl.class EchoImpl_Stub.class

# here the source of the server
[cyril@cyril echo]$ cat EchoAppliServer.java

import java.rmi.*;

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

try {
EchoImpl od = new EchoImpl();
Naming.rebind("rmi://localhost/echo",od);
System.out.println("\nEchoAppliServer:main()");

}
catch(Exception e) {
e.printStackTrace();

}
}
}

#first i start rmiregistry
[cyril@cyril echo]$ rmiregistry &
[1] 1699

# and then i launch the server but there is some exceptions
[cyril@cyril echo]$ java EchoAppliServer

EchoImpl:EchoImpl()
java.security.AccessControlException: access denied
(java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.lang.Throwable.<init>(Throwable.java:96)
at java.lang.Exception.<init>(Exception.java:44)
at java.lang.RuntimeException.<init>(RuntimeException.java:49)
at java.lang.SecurityException.<init>(SecurityException.java:41)
at
java.security.AccessControlException.<init>(AccessControlException.java:59)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:279)
at
java.security.AccessController.checkPermission(AccessController.java:405)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:551)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1050)
at java.net.Socket.<init>(Socket.java:274)
at java.net.Socket.<init>(Socket.java:112)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketF
actory.java:29)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketF
actory.java:124)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:512)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:194)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:178)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:161)
at EchoAppliServer.main(EchoAppliServer.java:11)

# So can you tell me what's wrong with this code?
Thanks

Cyril

2147483647 Alexander Derazhne

unread,
Feb 4, 2002, 11:09:55 AM2/4/02
to
Hello Cyril!

> System.setSecurityManager(new RMISecurityManager());

This is for client side.

> try {
> EchoImpl od = new EchoImpl();
> Naming.rebind("rmi://localhost/echo",od);
> System.out.println("\nEchoAppliServer:main()");

==========
hostName = java.net.InetAddress.getLocalHost().getHostName();
System.getProperties().put("java.rmi.server.codebase", "http://" +
hostName+"/");
theX = new TheX();
Naming.rebind("//" + hostName + "/" + XInterface.RMI_REGISTER_NAME, theX);
==========
Note. Extracted from working code

Alexander Derazhne


Phillip Chudley

unread,
Feb 4, 2002, 8:44:46 PM2/4/02
to
Hi Cyril

I also got the same problem, it was solved by storing a "policy file" in the
same folder as the server. I also needed the same "policy file" for the
client.

You can see an example in the JDK documentation. Look for "Remote Method
Invocation", then the "Getting started" tutorial. The policy file looks
like:

grant {
// Allow everything for now
permission java.security.AllPermission;
};


You then have to use a comannd like:

java -Djava.rmi.server.codebase=http://myhost/~myusrname/myclasses/ -Djava
.security.policy=$HOME/mysrc/policy examples.hello.HelloImpl

To execute the server (similarly for the client)

Hope this helps

Phillip Chudley

"Cyril Bérion" <ber...@site-eerie.ema.fr> wrote in message
news:a3lm8q$13o$1...@anais.site-eerie.ema.fr...

0 new messages