Solved

RMI callbacks

Posted on 1998-08-20
6
284 Views
Last Modified: 2013-12-29
We are using RMI to call a remote application's methods from an applet. We know that the reverse (ie. calling an applet's method from an application ) is also possible but we are not able to do it. Can u give us a step by step method with all the details (directory - name of server etc. ) and also suggest why it is not currently possible)
0
Comment
Question by:shyamala
6 Comments
 
LVL 4

Expert Comment

by:evijay
Comment Utility
applet must extend a remote interface, should be signed, register with the rmi registry with naming.bind, should not create rmi security manager. all the classes (stubs and skeletons) must be accessible to both application and applet (classpath and code base).



0
 
LVL 2

Expert Comment

by:threshold
Comment Utility
RmiRegistry is an .exe Application.
It could be run in the Client, but it's not a good solution.
And, It's not a good idea to open ServerSocket on Applet.
0
 

Accepted Solution

by:
knollc earned 150 total points
Comment Utility
Actually, you do not need to sign an applet to allow callbacks.  Its very simple:  You already have an applet which does a lookup to find a remote server.  So, the next thing you should do is have your APPLET implement a remote interface which the SERVER object understands (ie. the remote interface is in the classpath).  Then, your applet can call a remote object and pass as a parameter 'this' (meaning the applet itself) which will be the remote interface you have implemented in the applet.  So, here's how it looks:

public interface remote_appletInterface extends Remote
{
  myFirstFunction() throws RemoteException;
  myNextFunction() throws RemoteException;
}

public class MyApplet extends Applet implements remote_appletInterface
{  
  // applet code here for looking up remote server
  // next we need to implement the remote_appletInterface
  myFirstFunction();
  myNextFunction();
}

public server implements remote_Server
{
   // you already have code to allow the applet call the server methods
  // the next function allows a remote applet to register itself with the server for callbacks
  function notifyServer(remote_appletInterface remoteApplet)
  {
    // store the remote_appletInterface in a vector or a local var for later use.  
    // you may call the functions myFirstFunction() and myNextFunction() on the applet
    // because the applet implements this interface. So:
    remoteApplet.myFirstFunction();  // this is a callback!
  }

FINALLY:  somewhere in the applet (perhaps the start or init)

public void init()
{
   // look up the server
  remoteServer.notifyServer(this);  // by sending a remote interface to the server (namely, the applet), the server can then make calllbacks.
}

REMEMBER:  The rmic will be run on the applet class file to generate the stub and skel files that the SERVER will need to communicate back to the applet.  Make sure these files are accessable to the server and applet.  (the applet needs them to recieve calls from the server and the server needs them to make calls to the client).  

Hope this helps!

-Chris
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:shyamala
Comment Utility
Mr. Knolloc, Thanx for ur interest. I tried out your solution but I am getting Applet security exception. Can u give a more detailed answer, with the exact folder names in which the program resides (it is ok if it is hard coded) and all the other details
0
 

Expert Comment

by:knollc
Comment Utility
Sure.  According to netscape, you will get an applet security exception if the proxy/stub is found in the local machine's classpath.  You may have received an exception saying that you can not connect to <remote ip address> from <local class path>.  The reason is that the class loader in netscape found the proxy on your local machine, and the proxy is trying to connect to the web server.  Well, the proxy can only connect to the machine it was downloaded from (in this case, local), so you will get a security exception when you attepmpt the callback.  I also had this problem, but because of other activities I coudln't complete my tests.  I recommend you make sure all traces of the stub_ skel_ classes are removed from the local system and have them ONLY reside on the web server.  Then try the test.

Also, you only need rmiRegistry running on the web server (if that is where your server object is running, which, in the case of an applet call back, is required because the applet will only be able to connect to objects on the web server it was downloaed from).  I'll crack open the books and try to get my demo working and send you anything I am able to come up with.

-Chris

0
 

Expert Comment

by:knollc
Comment Utility
Here's some specifics and an example:

remote_Applet.class : interface to the applet
mainApplet.class : the applet that implements the remote_Applet interface.

remote_Server.class : interface to the server class
mainServer.class : the server object that implements the remote_Server interface

mainApplet_stub/skel : the proxy/stubs generated by calling rmic on mainApplet.class
mainServer_stub/skel: the proxy/stubs generated by calling rmic on the mainServer.class

Here's where the files should go:
remote_Applet.class  : in web server applet directory AND in classpath of server object (the server object needs it to make callbacks.)
mainApplet.class : in weber server applet directory
remote_Server.class : in web server applet directory AND in classpath of server object (the applet needs it to connect to the remote object)
mainServer.class : in the server classpath
mainServer_stub/skel : in web server applet directory AND in classpath of server object
mainApplet_stub/skel: in web server applet directory AND classpath of server object

Notice how both the applet and server objects need to have all the stub/skel classes in their classpaths.  this is because the stub/skel is doing the work of making the connection to each other and 'marshalling' the data being transfered from client to server.  if there was no callbacks being performed, only the server would need the skel and client need the stub in their classpaths.

I hope this helps a little bit.  I'll dig up some of my old work and try out some things and let you know if I get it to work!

-Chris

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
computer science syllabus 3 52
wordappend challenge 8 83
What is the latest versions eclipse neon 2 113
Java Jpanels and Jframe 8 19
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now