Chat on IRC |
Java RMI Help
Posted by Cobbs [send private reply] at November 18, 2001, 04:37:03 PM
I'm having trouble with this simple RMI server and client. Here's the code...
//this is Server.java import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class Server extends UnicastRemoteObject implements Person { public Server() throws Exception { super(); } public String talk() throws Exception { return "Hello!"; } public static void main(String[] args) throws Exception { System.setSecurityManager(new RMISecurityManager()); LocateRegistry.createRegistry(1099); Naming.bind("//Downstairs/Person", new Server()); } } //this is Client.java import java.rmi.*; public class Client { public static void main(String[] args) throws Exception { Person person = (Person) Naming.lookup("//Downstairs/Person"); System.out.println(person.talk()); } } //and this is the interface, Person.java import java.rmi.*; public interface Person extends Remote { public String talk() throws Exception; } I have no idea what's wrong with it. I get... C:\My Documents\rmi>java Boy Exception in thread "main" java.security.AccessControlException: access denied ( java.net.SocketPermission 192.168.0.2:1555 accept,resolve) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:273) at java.security.AccessController.checkPermission(AccessController.java: 404) at java.lang.SecurityManager.checkPermission(SecurityManager.java:545) at java.lang.SecurityManager.checkAccept(SecurityManager.java:1171) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermi ssion(TCPTransport.java:563) at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(TCPTransport .java:211) at sun.rmi.transport.Transport$1.run(Transport.java:150) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:147) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4 63) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport .java:704) at java.lang.Thread.run(Thread.java:539) java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is: java.io.EOFException at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 206) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:353) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at java.rmi.Naming.bind(Naming.java:113) at Boy.main(Boy.java:29) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:281) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 192) ... 4 more I get this after starting up the server, before i start up the client. I've been working on this for awhile... Thanks
Posted by Psion [send private reply] at November 18, 2001, 06:06:04 PM
I think it's pretty obvious that you need to add appropriate permissions to your java.policy file, or do whatever else is necessary to give your applications access to the network.
Posted by Cobbs [send private reply] at November 19, 2001, 05:25:30 PM
:\ That wasn't too bad. For some reason I thought that applications that weren't applets or webstart had all persmissions...
Posted by Psion [send private reply] at November 19, 2001, 05:30:04 PM
That's what Atilla the Hun thought, and we ended up with the War of the Roses for it.
Posted by gian [send private reply] at November 20, 2001, 12:04:45 AM
So true, so, so true.
Register as a new user | |||||||