java - RMI error while trying to get an applet from the server -


i'm working on simple rmi example, client try calling applet server. i've defined class called "simpleapplet" (the extends applet), on client side have 2 files: java files of server interface , 1 client code. on server side, have 3 files: 1 applet, 1 server interface , 1 implementation. server runs fine, error on client side, here is:

java.rmi.unmarshalexception: error unmarshalling return; nested exception is: java.lang.classnotfoundexception: simpleapplet (no security manager: rmi class loader disabled)

i think there's issue applet object, it's not recognized client, tried using casts (with applet) still have issue. happen know how solve problem ? !

here client side code

public class swingcall {      static applet a;      public static void main(string[] args) throws exception {          myrmiserverintf obj = (myrmiserverintf) naming.lookup("rmi://10.100.162.203:1100/newrmiserver");         a= (applet) obj.getapplet();          jframe frame = new jframe("window");         frame.setvisible(true);         frame.setsize(500, 200);         frame.setdefaultcloseoperation(jframe.exit_on_close);          jpanel panel = new jpanel();         frame.add(panel);         jbutton button = new jbutton("call applet");         panel.add(button);         button.addactionlistener(new action1());      }      static class action1 implements actionlistener {         public void actionperformed(actionevent e) {              a.init();              jframe frame = new jframe("myapplet");             frame.setvisible(true);             frame.setsize(500, 500);             frame.getcontentpane().add(a);             frame.setvisible(true);         }     } } 

this server side code:

public class myrmiserver extends unicastremoteobject implements myrmiserverintf {          public static final string message = "hello world";          public myrmiserver() throws remoteexception {             super(0);    // required avoid 'rmic' step, see below         }          public applet getapplet() {             simpleapplet app= new simpleapplet();             return (applet)app;         }          public static void main(string args[]) throws exception {             system.out.println("rmi server started");              try { //special exception handler registry creation                 locateregistry.createregistry(1101);                  system.out.println("java rmi registry created.");             } catch (remoteexception e) {                 //do nothing, error means registry exists                 system.out.println("java rmi registry exists.");             }              //instantiate rmiserver             myrmiserver obj = new myrmiserver();             system.out.println("after");             // bind object instance name "newrmiserver"             naming.rebind("rmi://localhost:1101/newrmiserver", obj);             system.out.println("peerserver bound in registry");         } } 

and here applet code:

public class simpleapplet extends applet {      jlabel l= new jlabel("120");      public void init() {          super.resize(500, 200);         super.add(l);         super.init();     } } 

the simpleapplet class file needs deployed @ client.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -