This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pushing Data from the RMI Server  RSS feed

Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?


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

java FlightClient2

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

Any one please help......
miguel roxo
Posts: 1
Linux Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!