• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pushing Data from the RMI Server

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

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......
 
Greenhorn
Posts: 1
Postgres Database Tomcat Server Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic