By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,191 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,191 IT Pros & Developers. It's quick & easy.

RMI first step

P: n/a
Hello,

For testing purpose, I'm trying to use RMI...
Here is the exception when I run Main.java :
Exception in thread "main" java.security.AccessControlException: access
denied (java.net.SocketPermission 192.168.0.1:1099 connect,resolve)
at
java.security.AccessControlContext.checkPermission (AccessControlContext.java
:264)
at
java.security.AccessController.checkPermission(Acc essController.java:427)
at java.lang.SecurityManager.checkPermission(Security Manager.java:532)
at java.lang.SecurityManager.checkConnect(SecurityMan ager.java:1034)
at java.net.Socket.connect(Socket.java:501)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:178)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.cre ateSocket(RMIDirectSocketF
actory.java:22)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.cre ateSocket(RMIMasterSocketF
actory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:569)
at
sun.rmi.transport.tcp.TCPChannel.createConnection( TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCP Channel.java:171)
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:160)
at testRMI.Main.main(Main.java:28)

(jdk1.5.0_01 - Win2000Pro - no firewall)
What am I doing wrong ?
Thanks for your help,
Martin.

The code :
================================================== =================
Main.java :
package testRMI;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.lang.SecurityException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class Main extends UnicastRemoteObject implements Meeting
{
private String ivDate = new String("25/3/2005");
private static final long serialVersionUID = 1;

public Main() throws RemoteException {

}

public String getDate() throws RemoteException {
return ivDate;
}

public static void main(String[] args) throws
AlreadyBoundException,RemoteException,
MalformedURLException,SecurityException {
System.setSecurityManager(new RMISecurityManager());
Main ms = new Main();
Naming.rebind("rmi://192.168.0.1/Meeting",ms);
}
}
================================================== =================
Meeting.java
package testRMI;

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

public interface Meeting extends Remote
{
public String getDate() throws RemoteException;
}
================================================== =================
ClientRMI.java
package testRMI;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.Remote;
import java.rmi.RemoteException;

public class ClientRMI
{
public static void main(String[] args)
throws RemoteException, MalformedURLException,NotBoundException {
System.setSecurityManager(new RMISecurityManager());
Remote r = Naming.lookup("rmi://192.168.0.1/Meeting");
String s = null;
if(r instanceof Meeting)
{
Meeting ms = (Meeting)r;
s = ms.getDate();
}
System.out.println(s);
}
}
================================================== =================

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hey,

in the lib/security directory of your JDK installation are policy
files, you should take a look at these....

David
--------------------------
http://blog.linsin.de

Jul 18 '05 #2

P: n/a
Yep ... I forgot that part.
Thanks David !
Problem solved

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.