File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Pushing Data from the RMI Server Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Reply Bookmark "Pushing Data from the RMI Server" Watch "Pushing Data from the RMI Server" New topic
Author

Pushing Data from the RMI Server

Vinodh Sa
Ranch Hand

Joined: May 06, 2010
Posts: 55
Hi All,

I m totally new to RMI. I started learning RMI yesterday only, when i came through the RMI chapter in J2EE Bible.

I m facing one problem when i m using the concept of "Pushing Data from the RMI server".

I m getting the "Access denied" exception in client side when i try to call a method of server side code, inspite of having the security.policy file.

Can anyone help me in this ?

Code:




After starting the rmi registry and the FlightServer2, i m running the flight client2 using the following command

java -Djava.security.policy=security.policy FlightClient2

But i m getting, "Access Denied" exception after abt 30 seconds.....

Any one please help......


Thanks, Vinodh
[Servlet tutorial]
miguel roxo
Greenhorn

Joined: Aug 19, 2011
Posts: 1

hi Vinodh,
why are you exporting the client?
"UnicastRemoteObject.exportObject(fc); " in line 102;

I'm guessing you're trying to do something asynchronous with your RMI app, but to do that you just have to use a callback in the client and pass the reference to the server and it will notify the client when it's done; you can Google more info about callback easily;
But usually RMI works in a direct way:
-client request the server reply an object;

And the server is the one who as to be exported not the client;

You may do one of these:
- if your server extends UnicastRemoteObject, you don't need to export it;
- or else:
server = new ClassServer();
RemoteInterfaceExtendedByServerClass stub=(RemoteInterfaceExtendedByServerClass) UnicastRemoteObject.exportObjct(server);

This code is follows one of the options above.
Registry registry =LocateRegistry.createRegistry(port_where_your_server_will_listen_for_requests);
registry.rebind("the_name_of_the_RMI_service",server);
while(true){
Thread.currentThread();
Thread.sleep(100);
}

Now the server is registed in the service names and binded to a port;

In the client you just have to do this:

RemoteInterfaceExtendedByServerClass client = null;
Registry registry = LocateRegistry.getRegistry("your_server_ip or name, if same machine then localhost",port_where_your_server_will_listen_for_requests);
client = (RemoteInterfaceExtendedByServerClass) registry.lookup(RemoteInterfaceExtendedByServerClass);

and after this you can call any function in your RemoteInterfaceExtendedByServerClass interface;

Regards, hope this helps you.
Miguel Roxo
 
 
subject: Pushing Data from the RMI Server
 
Threads others viewed
Not able to use two ports in RMI chat application
jsp vs rmi
Read a file line by line
running a rmi sample
Implemet rmi Client on an Applet
IntelliJ Java IDE