I have a RMI problem (on Windows 95), which leads to this error after a few
seconds:
java.rmi.ServerException: RemoteException occurred in server thread; nested
exception is:
java.rmi.AccessException: Registry.rebind: unknown host
java.rmi.AccessException: Registry.rebind: unknown host
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Compil
ed Code)
at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:165)
at RemoteServer.main(RemoteServer.java:36)
The intention is to run the client and the server on the same machine, but I
never get to the client stage.
Here are the steps I take:
1)
set CLASSPATH=
rmiregistry
2) in a separate console window, in the directory c:/Data/Java/rmi/
javac RemoteServer
rmic RemoteServer
3)
run it from c:/Data/Java/rmi/. I've tried various alternatives:
java -Djava.security.policy=java.policy -Djava.rmi.server.codebase=file:///c
:/Data/Java/rmi/ RemoteServer
java -Djava.security.policy=java.policy -Djava.rmi.server.codebase=file:c:/D
ata/Java/rmi/ RemoteServer
java -Djava.security.policy=java.policy -Djava.rmi.server.codebase=file:///D
ata/Java/rmi/ RemoteServer
java -Djava.security.policy=java.policy RemoteServer
They all lead to the same error.
Can anyone help?
TIA
David
------------------------------------------------------
Source code:
------------------------------------------------------
Send.java
------------------------------------------------------
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Send extends Remote {
public void sendData(String text) throws RemoteException;
public String getData() throws RemoteException;
}
------------------------------------------------------
RemoteServer.java
------------------------------------------------------
import java.rmi.*;
import java.rmi.server.*;
class RemoteServer extends UnicastRemoteObject implements Send {
private String text;
public RemoteServer() throws RemoteException {
super();
}
public void sendData(String gotText){
text = gotText;
}
public String getData(){
return text;
}
public static void main(String[] args){
System.setSecurityManager(new RMISecurityManager());
String name = "Send";
try {
Send remoteServer = new RemoteServer();
Naming.rebind(name, remoteServer);
System.out.println("SUCCESS");
} catch (Exception e) {
System.out.println("FAIL");
e.printStackTrace();
}
}
}
------------------------------------------------------
java.policy
------------------------------------------------------
grant {
permission java.security.AllPermission;
};
hi David,
for me it seems as if you haven't started the
rmiregistry. Therefor you need the command
start rmiregistry or
javaw rmiregistry
You can find a detailed description for all
needed steps in the original SUN Java
documentation:
Start the RMI registry
The RMI registry is a simple server-side
name server that allows remote clients to get a
reference to a remote object. Typically, it is
used only to locate
the first remote object an application needs
to talk to. Then that object in turn would
provide application-specific support for finding
other objects.
Note: Before you start the rmiregistry, you
must make sure that the shell or window in which
you will run the registry either has no
CLASSPATH set or has a CLASSPATH that does
not include the path to any classes that you want
downloaded to your client, including the
stubs for your remote object implementation
classes.
If you start the rmiregistry, and it can
find your stub classes in its CLASSPATH, it will
ignore the server's java.rmi.server.codebase
property, and as a result, your client(s)
will not be able to download the stub code for
your remote object. For an explanation of how code
downloading works in RMI, please take a look
at the tutorial on Dynamic code downloading using
RMI.
To start the registry on the server, execute
the rmiregistry command. This command produces no
output and is typically run in the background. For
more on the rmiregistry, you can refer to
the Solaris rmiregistry manual page or the Win32
rmiregistry manual page.
For example, in the Solaris operating
environment:
rmiregistry &
For example, on Microsoft Windows 95
systems:
start rmiregistry
(Use javaw if start is not available.)
By default, the registry runs on port 1099.
To start the registry on a different port,
specify the port number from the command line.
For example, to
start the registry on port 2001 on a
Microsoft Windows NT system:
start rmiregistry 2001
If the registry is running on a port other
than 1099, you'll need to specify the port number
in the name handed to the URL-based methods of the
java.rmi.Naming class when making calls to
the registry. For example, if the registry is
running on port 2001 in this example, the call
required to bind
the name "HelloServer" to the remote object
reference would be:
Naming.rebind("//myhost:2001/HelloServer",
obj);
You must stop and restart the registry any
time you modify a remote interface or use
modified/additional remote interfaces in a remote
object
implementation. Otherwise, the type of the
object reference bound in the registry will not
match the modified class.
hope this helps
:-) CARSTEN
Sent via Deja.com http://www.deja.com/
Before you buy.
bye, Helmuth
<schl...@my-deja.com> wrote in message news:8rulnj$l5d$1...@nnrp1.deja.com...