Today for the first time using RMI to write a remote method call write program, I would like to test the RMI write a simple example, the code is as follows:
/*
*create on Dec 31, 2008
*copyright 2009 Quasar20063501.all Rights reserved
*
*weizhaozhe
*/
Wzz.server.Server.java
Package wzz.server;
Import java.rmi.*;
Import wzz.service.*;
public class Server {
public static void Main (String args[]) {
try{
Rmtserviceimpl service=new Rmtserviceimpl (); Remote Port implementation Class object
String registration= "Rmi://localhost:8888/rmtservice";
Naming.rebind (registration, service); Registering a remote service
}catch (RemoteException re) {
System.out.println ("There is a remoteexception happened!/n");
System.out.println ("Details:" +re);
}catch (Exception e) {
System.out.println ("There is a Exception happened!/n");
}
}
}
There is basically no complex function, which is written according to the Java API's QuickStart, but it throws java.rmi.RemoteException exception at runtime. So I checked the code from the beginning, did not find any mistake, went to find the more familiar with the classmate, the classmate "look and see", also did not find errors, so we have been studying, from 5:00 to 7:00, after I have watched for some time, and finally did not find mistakes, Determines that the exception that is thrown by Naming.rebind () is unable to find the distribution class Xxx_stub.class corresponding to the service object, because rebind actually calls the rebind method of this class, so it throws an exception all the time, but I have generated rmic using the Xxx_ tool Stub.class, in the bin directory is visible, why. Is it not configured with path, but we find out by configuration, engage in dizziness brain up, I do not know how, the last roommate also said that the RP (character) problem, hey, finally, the original path has been configured with the current path conflict with it, anyway, I put the environment variable tidy up a bit, really hateful ridiculous, 3 hours and found this "anomaly".
Now that the problem is getting a little depressed, but still want to share with you my experience, I think we will often happen in the programming of this situation, encountered a moment how also can not solve the mistake, it may take a long time, this time must be very uncomfortable, but we must insist ah, another way of thinking, It may be suddenly enlightened. Blog for the first time, please give us a lot of advice ah.
Finally, in 2009, we hope that our health and technology will be improved. Happy New Year's day.