Thanks friend,
You are right that If someone is publishing a remote object for general consumption, he/she also publishes the RemoteInterface which the clients can use. But how client will get that Remote Interface,ultimately server has to give it manually to the client.....
I am also not able to use this codebse dynamically.
and one more problem i am getting...
I am not able to run my server using codebase and that policy file its throwing some exception...
The description is like this...
C:\Documents and Settings\NEWUSER\Desktop\java prgs\RMI_TEST>
java -cp .;./comput
e.jar -Djava.security.policy=server.policy engine.ComputeEngine
ComputeEngine exception:
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:35)
and my server class is like this
/////
////
package engine;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import compute.Compute;
import compute.Task;
public class ComputeEngine implements Compute{
public ComputeEngine(){
super();
}
public <T> T executeTask(Task<T> t){
return t.execute();
}
public static void main(
String arg[]){
String codebase = "http://192.168.61.92:2001/";;
System.setProperty( "java.rmi.server.codebase", codebase );
//System.setProperty( "java.security.policy", codebase+"server.policy" );
if(System.getSecurityManager()==null){
System.setSecurityManager(new SecurityManager());
}
try{
String name="Compute";
Compute engine=new ComputeEngine();
Compute stub=(Compute)UnicastRemoteObject.exportObject(engine,0);
Registry registry=LocateRegistry.getRegistry();
registry.rebind(name,stub);
System.out.println("ComputeEngine bound");
}catch(Exception e){
System.err.println("ComputeEngine exception:");
e.printStackTrace();
}
}
}
Please help me in this regard also...