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

another HelloImpl/RMI problem

8 views
Skip to first unread message

malal...@my-deja.com

unread,
Mar 13, 2000, 3:00:00 AM3/13/00
to
I am having problems (like many others) with running the RMI
tutorial/example that is on the Java.sun.com website as well as the
JBiulder3 help file.
Any help would be greatly appreciated, I think I'm missing the big
picture (cartoons would help).

Thanks in advance,
Malcolm L.


I ran this code with the default permissions in place:
//***********************************
// Hello interface...
package examples.hello;

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
//***********************************
// Hello server...
package examples.hello;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;

public class HelloImpl extends UnicastRemoteObject implements Hello {

public HelloImpl() throws RemoteException {
super();
}
public String sayHello() {
return "Hello World!";
}
public static void main(String args[]) {
int flag = 0;
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
HelloImpl obj = new HelloImpl();
Naming.rebind("//localhost/HelloServer", obj);
System.out.println("HelloServer bound in registry");
}
catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
//***********************************
//the default java.policy
// Standard extensions get all permissions by default

grant codeBase "file:${java.home}/lib/ext/-" {
permission java.security.AllPermission;
};

// default permissions granted to all domains

grant {
// Allows any thread to stop itself using the
java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to
remain
// backwards compatible.
// It is strongly recommended that you either remove this
permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially
unsafe.
// See "http://java.sun.com/notes" for more information.
permission java.lang.RuntimePermission "stopThread";

// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "localhost:1024-",
"listen";

// "standard" properies that can be read by anyone

permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url",
"read";
permission java.util.PropertyPermission "java.class.version",
"read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator",
"read";
permission java.util.PropertyPermission "path.separator",
"read";
permission java.util.PropertyPermission "line.separator",
"read";

permission java.util.PropertyPermission
"java.specification.version", "read";
permission java.util.PropertyPermission
"java.specification.vendor", "read";
permission java.util.PropertyPermission
"java.specification.name", "read";

permission java.util.PropertyPermission
"java.vm.specification.version", "read";
permission java.util.PropertyPermission
"java.vm.specification.vendor", "read";
permission java.util.PropertyPermission
"java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version",
"read";
permission java.util.PropertyPermission "java.vm.vendor",
"read";
permission java.util.PropertyPermission "java.vm.name", "read";
};
//**********************************************************************
*******
//* I get the following output/error messages
HelloImpl err: access denied (java.net.SocketPermission 127.0.0.1:1099
connect,resolve)
java.security.AccessControlException: access denied
(java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(Compiled
Code)
at java.security.AccessController.checkPermission(Compiled Code)
at java.lang.SecurityManager.checkPermission(Compiled Code)
at java.lang.SecurityManager.checkConnect(Compiled Code)
at java.net.Socket.<init>(Socket.java:258)
at java.net.Socket.<init>(Socket.java:98)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSoc
ketFactory.java:29)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSoc
ketFactory.java:124)
at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:462)
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:306)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:165)
at examples.hello.HelloImpl.main(HelloImpl.java:22)
//*******************************************************************

//*******************************************************************
// If I change java.policy to this only

grant{
permission java.security.AllPermission;
};

//*******************************************************************
// I get the following output/error messages
HelloImpl err: Connection refused to host: localhost; nested exception
is:
java.net.ConnectException: Connection refused: no further
information
java.rmi.ConnectException: Connection refused to host: localhost; nested
exception is:
java.net.ConnectException: Connection refused: no further
information
java.net.ConnectException: Connection refused: no further information
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
at java.net.Socket.<init>(Socket.java:269)
at java.net.Socket.<init>(Socket.java:98)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSoc
ketFactory.java:29)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSoc
ketFactory.java:124)
at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:462)
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:306)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:165)
at examples.hello.HelloImpl.main(HelloImpl.java:22)


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages