RMI Help

Hi,
Can any one help me in this problem ?
I'm getting the following error When the server responses to the client call.
java.rmi.UnmarshalException! error unmarshalling return; nested Exception is
java.io.StreamCorruptedException
at sun.rmi.Server.UnicastRef. invoke
The problem is with client side When processing the server side response..
Thanks for spending ur time.

Hi,
check out the official tutorial at http://java.sun.com/j2se/1.4/docs/guide/rmi/getstart.doc.html
Patrick

Similar Messages

  • Sockets in rmi, help needed

    hi,
    I need a help on using sockets in rmi for communication between the server and the client. I am trying to establish a communication between the server and client through sockets after the remote method call is invoked but before it is fulfilled. I my code the socket is not establishing in the client side. Do help me out at the earliest pls... thanks in advance..

    I am trying to use sockets inside a rmi. Still i have the problem. I cant get my client listen from the server.
    First the client invokes a remote object. Before server sending the actual request of the requested by the remote object i want to make some communication between the server and client through sockets.
    I created a ServerSocket in the client side. The problem I have is the ServerSocket is not listening to the server request.
    Here i ve my code.I cant figure out what mistake i have done. It also dont show any error. As i am new to RMI and sockets i am in need of help. So pls do help me... Thanks in advance.
    In my example i am trying to verify the password before the server downloads the file for the client. So i want the verification done through sockets and download file using RMI.
    FileInterface.java
    import java.rmi.*;
    public interface FileInterface extends Remote
    public byte[] downloadFile(String fileName) throws RemoteException;
    FileServer.java
    import java.rmi.*;
    import java.io.*;
    public class FileServer
    public static void main(String []args)
      if(System.getSecurityManager()==null)
       System.setSecurityManager(new RMISecurityManager());
      try
       FileImpl fi=new FileImpl("FileServer");
       Naming.rebind("FileServer",fi);
         System.out.println("Server bound"+fi);
      catch(Exception e)
       System.out.println("FileServer: "+e.getMessage());
    FileImpl.java
    import java.io.*;
    import java.net.*;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    public class FileImpl extends UnicastRemoteObject implements FileInterface
    private String name;
    public FileImpl(String s) throws RemoteException
      super();
      name=s;
    public byte[] downloadFile(String fileName)
      try
       Socket soc=new Socket(RemoteServer.getClientHost(),5000);
       OutputStream os=soc.getOutputStream();
       PrintStream ps=new PrintStream(os);
         System.out.println("Going to send message");
       ps.println("Enter the password : ");
         System.out.println("Sent message");
       InputStream is=soc.getInputStream();
       InputStreamReader isr=new InputStreamReader(is);
       BufferedReader br=new BufferedReader(isr);
       String res=br.readLine();
       PasswordControl pc=new PasswordControl(res,br);
       System.setSecurityManager(pc);
       File file=new File(fileName);
       byte [] buffer=new byte[(int)file.length()];
       BufferedInputStream input=new BufferedInputStream(new FileInputStream(fileName));
       input.read(buffer,0,buffer.length);
       input.close();
       return(buffer);
      catch(Exception e)
       System.out.println("FileImpl: "+e.getMessage());
       e.printStackTrace();
       return(null);
    public class PasswordControl extends SecurityManager
    String password;
    BufferedReader br;
    public PasswordControl(String password,BufferedReader br)
      this.password=password;
      this.br=br;
    public boolean accessOk()
      String response = "";
      try
       if(response.equals(password))
        return true;
       else
        return false;
      catch(Exception e)
       return false;
    public void checkRead(String fname)
      if(fname.equals("sample.txt"))
       if(!accessOk())
        super.checkRead(fname);
        throw new SecurityException("Access denied to read from the file sample.txt");
       else
        FilePermission fp=new FilePermission(fname,"read");
        checkPermission(fp);
    FileClient.java
    import java.io.*;
    import java.net.*;
    import java.rmi.*;
    public class FileClient  implements Runnable {
         Socket soc;
         String filename;
         byte[] filedata;
         public FileClient(String filename, String host)
         this.filename = filename;
         try
             ServerSocket ss=new ServerSocket(5000);
          System.out.println("Created a socket"+ss);
             String name = "//" + host + "/FileServer";
             FileInterface fi = (FileInterface) Naming.lookup(name);
          System.out.println("Got the interface "+fi);
             while(true)
           soc=ss.accept();
           new Thread(this).start();
            } catch(Exception e)
              e.printStackTrace();
           public static void main(String argv[]) {
            if(argv.length != 2) {
            System.out.println("Usage: java FileClient fileName machineName");
            System.exit(0);
         new FileClient(argv[0], argv[1]);
         public void run() {
         try {
         System.out.println(soc);
          InputStream is=soc.getInputStream();
          InputStreamReader isr=new InputStreamReader(is);
             BufferedReader br=new BufferedReader(isr);
         System.out.println("Created the readers"+br);
             String req=br.readLine();
          System.out.println("Going to print request");
          System.out.println(req);
          String password=br.readLine();
             OutputStream os=soc.getOutputStream();
          PrintStream ps=new PrintStream(os);
          ps.println(password);
             filedata = fi.downloadFile(filename);
             File file = new File(filename);
             BufferedOutputStream output = new
               BufferedOutputStream(new FileOutputStream(file.getName()));
             output.write(filedata,0,filedata.length);
             output.flush();
             output.close();
         } catch(Exception e) {
              e.printStackTrace();
    }

  • Beginner RMI help needed

    Hello all,
    I have fallen into a major problem. i am trying to get my first RMI system working and have looked numerous places for help. I have followed http://patriot.net/~tvalesky/easyrmi.html and cannot get passed running the client program.
    The coding is the same as the tutorial, i get the following errors...
    D:\RMI>java myRMIClient 10.0.0.7
    Exception occured: java.security.AccessControlException: access denied (java.net
    .SocketPermission 127.0.0.7:1099 connect,resolve)
    D:\RMI>java -Djava.security.policy="d:\RMI\wideopen.policy" myRMIClient 127.0.0.1
    Exception occured: java.rmi.NotBoundException: myRMIImplInstance
    ------wideopen.policy------
    grant {
    // Allow everything for now
    permission java.security.AllPermission;
    I really appreciate anyone who can help me. It is pretty urgent as i need to get this first exercise working.
    Many thanks, Riku

    Hello All,
    Many thanks for your advice,
    I have taken off the quotes and have tried to run the policy file on the server.
    When i launch rmiregistry on command prompt it shows on firewall:
    Protocol----Executable-------     Remote-----------Local----------------- Sent---------Recieved
    TCP______rmiregistry_____---___________Host Name:1099__0________0
    I then start myRMIServer
    On the command prompt it hangs on java -Djava.security.policy=d:\RMI\wideopen.policy myRMIServer 127.0.0.1
    On the firewall it states:
    TCP______java.exe______Host Name:1099_Host Name:1691__252________37
    That TCP dissapears after a timeout but on command prompt it hangs until i press CTRL+C
    I cannot explain what is happening there.
    I am not experienced enough to understand the code either.
    I really appreciate if you can give me more guidance on this.
    Thanks, Riku :)

  • J2me  RMI HELP

    hy to all,
    I'm new with j2me.
    I must develop an java rmi client for hp6915.
    what jvm version I must download??
    I downloaded Mysaifu jvm. It is rmi rmi enabled???

    There is no direct RMI support in J2ME like in J2SE. You have to use something else for your communications. The most commonly used way (and in fact the only way that is mandatory in the MIDP 2.0 spec) is via a HTTP or HTTPS connection. For more information see the MIDP 2.0 spec, in particular the section about the General Connection Framework.

  • JAVA RMI Help Please

    Hi
    I have an client
    - Client.java
    and two servers
    - ServerOneInterface.java
    - ServerOneImpl.java
    - ServerTwo1Interface.java
    - ServerTwoImpl.java
    The client can communicate with the servers fine, but how do i make the servers communicate with each other? What is the idea between making the servers communicate with each other?
    Thanks

    why not use the same concept and make each server behave as a client of the other...

  • Understanding benefits of RMI

    I am starting out on a new project where one of the key aims is to free up the current hold on application licenses that users have. Users currently log in, grab hold of a license, access the external system the image is for, and don't free up the license until they log out. I want to change this to be a web application with some sort of control over the availability of licenses. I don't know if RMI is what I need but i want to have a central class, with a method to login to the external application, get the object back they need, and logout again, thus freeing up the license again. I want all 400 users to use this one method but 'host it' on another machine not the web server.
    The crux of my problem is that I want this class to run more like a pool of licenses that are grabbed, used and freed up immediately. I just don't know the right technology to do it! How would RMI help with this problem?

    You seem to be talking about writing a front-end to your licensed server - whatever that is.
    As I understand your proposed process, your users make requests resulting in small atomic access to your licensed server. However your users are doing direct login/logout, and they hold a license in the entire interval.
    Your users can just as well log into your front-end server. You can allow them to stay logged in as long as they wish, but your front-end server will, in fact, do the actual login/query/logout on the "real" server.
    Sounds like a worthy project for RMI.
    o Your client programs make RMI requests to your front-end server.
    o Your front-end server does whatever authentication is required, returns some kind of a session object to the client.
    o Client makes a data request (passing the session object.)
    o Front end looks up the session object, uses the authetication data to access the real server, returns to the client the required data.
    o Client eventually logs out, passing the session object. Your front-end server eliminates the session from its records.
    Those user requests are inherently multi-threaded. You can use either a single license, or manage a pool. You simply block any pending requests until a license is available.
    You might want to check if doing this kind of thing invalidates your server license, or violates the licensing terms.

  • How to run a java program in windows 2003 server from unix server.

    Hi ,
    I want to run a java program in windows 2003 server from unix machine ..
    will RMI helps me to obtain this.
    Please tell me the procedure to do this.
    Thanks in advance,

    rmi,web services,corba,web 2.0,xml,xls,dtd,rss,ruby on rails,https,soap,tags,blog,podcast,google

  • Network Adapter Programming in Java

    Hi all,
    I need to send a signal from my computer to antoher computer using a Java program. The two computers are connected with the help of a network adapter (like an ethernet card). How can I do this in java? Is RMI helpful in this scenario? Any help or examples will be appreciated.

    Hi,
    I have two network adapters on the same computer
    and I have configured them to use a parrrticular ip
    addresses. Now I connected them using ethernet card.
    I am using socket program to send the signal between
    the two adapters. I have the problem like i get same
    ip address for both client and server, ie i cannot
    run client one ip address (10.1.1.1) and server on
    the other ip address(10.1.1.2). Is there any other
    way to approach the problem? Any suggestions?Is this for testing? If not please help me understand why you are using the network adapters and sockets instead of just communicating directly? Thanks

  • Help me to run this simple RMI example

    When i m running this example in standalone pc it works but while running on to different pc it gives error though I m giving the IP address from client of server.. If anyone can help me out plz help.
    Code:
    ReceiveMessageInterface
    import java.rmi.*;
    public interface ReceiveMessageInterface extends Remote
    void receiveMessage(String x) throws RemoteException;
    Server code:
    import java.rmi.*;
    import java.rmi.registry.*;
    import java.rmi.server.*;
    import java.net.*;
    public class RmiServer extends java.rmi.server.UnicastRemoteObject
    implements ReceiveMessageInterface
    int thisPort;
    String thisAddress;
    Registry registry; // rmi registry for lookup the remote objects.
    // This method is called from the remote client by the RMI.
    // This is the implementation of the �ReceiveMessageInterface�.
    public void receiveMessage(String x) throws RemoteException
    System.out.println(x);
    public RmiServer() throws RemoteException
    try{
    // get the address of this host.
    thisAddress= (InetAddress.getLocalHost()).toString();
    catch(Exception e){
    throw new RemoteException("can't get inet address.");
    thisPort=3232; // this port(registry�s port)
    System.out.println("this address="+thisAddress+",port="+thisPort);
    try{
    // create the registry and bind the name and object.
    registry = LocateRegistry.createRegistry( thisPort );
    registry.rebind("rmiServer", this);
    catch(RemoteException e){
    throw e;
    static public void main(String args[])
    try{
    RmiServer s=new RmiServer();
    catch (Exception e) {
    e.printStackTrace();
    System.exit(1);
    Client code:
    import java.rmi.*;
    import java.rmi.registry.*;
    import java.net.*;
    public class RmiClient
    static public void main(String args[])
    ReceiveMessageInterface rmiServer;
    Registry registry;
    String serverAddress=args[0];
    String serverPort=args[1];
    String text=args[2];
    System.out.println("sending "+text+" to "+serverAddress+":"+serverPort);
    try{
    // get the �registry�
    registry=LocateRegistry.getRegistry(
    serverAddress,
    (new Integer(serverPort)).intValue()
    // look up the remote object
    rmiServer=
    (ReceiveMessageInterface)(registry.lookup("rmiServer"));
    // call the remote method
    rmiServer.receiveMessage(text);
    catch(RemoteException e){
    e.printStackTrace();
    catch(NotBoundException e){
    e.printStackTrace();
    }

    When we compile with rmic skeleton and stub get created then we hav to place stub at each client ???Your remote client applcation need only _Stub.class fiels.
    Is there way by which we can know how many clients are connected to the
    server and there IP address, can anyone give the code... I guess that you should use a RMI login/logout method to register/unregister your client connection information into a databse or a simple static Hashtable(Vector) object.

  • Please help: RMI and Swing/AWT issue

    Hi guys, I've been having a lot of trouble trying to get a GUI application to work with RMI. I'd appreciate any help. Here's the story:
    I wrote a Java application and its GUI using Netbeans. In a nutshell, the application is about performing searches. I am now at the point where I need exterior programs to use my application's search capabilities, thus needing RMI. Such exterior programs are to call methods currently implemented in my application.
    I implemented RMI, and got the client --> server communication working. However, the GUI just breaks. It starts outputting exceptions, gets delayed, doesn't update properly, some parts of it stop working.... basically hysterical behavior.
    Now take a look at this line within my server class:
    Naming.rebind("SearchProgram", mySearchProgram);
    If I take it out, RMI obviously does not work... but the application and its GUI work flawlessly. If I put it in, the RMI calls work, but the GUI's above symptoms occur again. Among the symptoms are null pointer exceptions which all look similar, are related to "AWT-EventQueue-0", and keep ocurring. Here's just snippet of the errors outputted:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.plaf.metal.MetalScrollBarUI.getPreferredSize(MetalScrollBarUI.java:102)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
    at javax.swing.JScrollBar.getMinimumSize(JScrollBar.java:704)
    at javax.swing.ScrollPaneLayout.minimumLayoutSize(ScrollPaneLayout.java:624)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:634)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:634)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at javax.swing.BoxLayout.checkRequests(BoxLayout.java:433)
    at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:375)
    at java.awt.Container.layout(Container.java:1401)
    at java.awt.Container.doLayout(Container.java:1390)
    at java.awt.Container.validateTree(Container.java:1473)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validate(Container.java:1448)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:379)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:113)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredMenuItemSize(BasicMenuItemUI.java:400)
    at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(BasicMenuItemUI.java:310)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
    at javax.swing.BoxLayout.checkRequests(BoxLayout.java:434)
    at javax.swing.BoxLayout.preferredLayoutSize(BoxLayout.java:251)
    at javax.swing.plaf.basic.DefaultMenuLayout.preferredLayoutSize(DefaultMenuLayout.java:38)
    at java.awt.Container.preferredSize(Container.java:1558)
    at java.awt.Container.getPreferredSize(Container.java:1543)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
    at javax.swing.JRootPane$RootLayout.layoutContainer(JRootPane.java:910)
    at java.awt.Container.layout(Container.java:1401)
    at java.awt.Container.doLayout(Container.java:1390)
    at java.awt.Container.validateTree(Container.java:1473)
    at java.awt.Container.validate(Container.java:1448)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:379)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:113)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    There are no complaints about anything within my code, it's all GUI related whenever I make a bind() or rebind() call.
    Again, any help here would be great... cause this one's just beating me.
    Thanks!

    Maybe you want to change that worker thread to
    not do RMI but anything else (dummy data) to see if it really is RMI, I doubt it, I think you are updating some structures that have to do with swing GUI and hence you will hang.
    Just check this out.

  • Help needed in running the RMI application with multiple clients

    Hi
    I have my RMI application with one server and 6 clients. I keep all the server and client programs in the same directory. When i run the clients, the first 2 clients work properly but when the third or the fourth client starts, it works normally in getting the data and after a while it crashes. If teh third crashes the 4th works and if the 4th crashes the 3rd, 4th and 5th works ...randomly atleast one or 2 clients crash always.
    following is the error message generated for a client named controller:
    [ code ]
    Exception in thread "main" java.lang.NullPointerException
    at PostOfficeImpl.isinputAvail(PostOfficeImpl.Java:315)
    at PostOfficeImpl_Skel.dispatch(Unknown Source)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
    at sun,rmi.transport.Transport$1.run(Transport.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun,rmi.transport.Transport.serviceCall(Transport.java:149)
    at sun,rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    at sun,rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    at java.lang.Thread.run(Thread.java:595)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
    at PostOfficeImpl_Stub.isinputAvail(Unknown Source)
    at CONTROLLER.main(CONTROLLER.java:167)
    my ser ver program is as follows:
    class PostOfficeServer extends java.rmi.server.UnicastRemoteObject implements java.rmi.Remote {
    // Instance of ourselves
    public static String name;
    private static PostOfficeServer rmi;
    // public No-argument constructor
    public PostOfficeServer() throws RemoteException {
         super();
    public static void main(String[] args){
    if(System.getSecurityManager() == null) {
         System.setSecurityManager(new RMISecurityManager());
    try {
         new PostOfficeServer();
         PostOffice postOfficeserver = new PostOfficeImpl();
    try {
         getIP ipAdd1 = new getIP();
         String ip1 = ipAdd1.getIP();
         name = "//" + ip1 + "/PostOffice";
    catch (Exception e){
         System.out.println();
    Naming.rebind(name, postOfficeserver);
    System.out.println("RemoteServer bound");
    System.out.println("initialise Data Structure");
    postOfficeserver.initDatastructure();
    System.out.println("initilised");
    catch (java.rmi.RemoteException e) {
         System.out.println("Cannot create remote server object");
    catch (java.net.MalformedURLException e) {
         System.out.println("Cannot look up server object");
    System.out.println("Server started.");
    System.out.println("Enter <CR> to end.");
    try {
         int serve2end = System.in.read();
    }catch (IOException ioException) {
    System.exit(0);
    //endoffilePlease advise as this is very urgent

    Hi
    the following is the code for PostOfficeImpl...its a long code but i include it so that I get your help please...
    import java.io.*;
    import java.net.*;
    import java.lang.*;
    import java.rmi.*;
    import java.rmi.server.*;
    import java.rmi.RemoteException;
    import java.util.HashMap;
    import java.util.*;
    public class PostOfficeImpl extends java.rmi.server.UnicastRemoteObject implements PostOffice {
    //Implementations must have an explicit constructor in order to declare the
    //RemoteException exception
    public PostOfficeImpl() throws java.rmi.RemoteException {
         super();
    public static LinkedListImpl list = new LinkedListImpl();
    public static oListImpl ovarList  = new oListImpl();
    public static iListImpl ivarList =new iListImpl();
    public static lipsList llfirst;
    public static oList opchannel, ofirst, onext;
    public static iList ipchannel, ichan, ifirst;
    public static  String[] variNumber= new String[100];
    public static String[] inoutChan, inChan, outChan,inVAR, invarLIST,outVAR, outvarLIST ;
    public static String[][] driveMat;
    DriverMatrix_mthds drive = new DriverMatrix_mthds();
    private static  Boolean All_Vacant;
    private static  Boolean tAll_Vacant;
    public void sendAll_Vacant(Boolean All_Vacant) throws RemoteException {
         tAll_Vacant = All_Vacant;
    public Boolean getAll_Vacant() throws RemoteException{
          return tAll_Vacant;
    public  void initDatastructure() throws RemoteException{
    ifirst = null;
    ofirst=null;
    int i=0, j=0, k=0, ind1=0, ind2=0;
    try{/// initialise list
         drive = new DriverMatrix_mthds();
         drive.VarTypeArray();
         drive.nodeHeadVarType();
         String[] variablel = drive.Variablelist();
         drive.lipsvariablist();
         drive.NodeOrigin();
    drive.nodeInput();
         drive.numOfnodes();
         drive.noOfVariables();
         drive.Assignlist();
         drive.novarType();
         drive.varNameType();
         drive.nodeNumName();
         drive.driverMat();
         String[][] lookupvar = drive.varNameType();
         //tempdrive = drive.driverMat();
         long leng1 = variablel.length;
         int varlistlength = (int) leng1;
         int counter;
         String s1="";
         String s2="";
         String s3 = "";
         String s4 = "";
         String s6 = "";
         int s5=0, c=0;
         while(variablel[k] !=null){
              k=k+1;
         int i1, j1;
         String  varname, varnumber;
         varnumber = "";
    while(i<=variablel.length-1){
         if(variablel!=null){
         c=c+1;
         i=i+1;
    try{
         ind1=0; ind2 = 0;i=0;
    while(!(variablel[i].equals("end of file"))){
         s1 = variablel[i];
         i=i+1;
         s2 = variablel[i];
         i=i+1;
         System.out.println("     " + s1+"     "+s2);
    while(!(variablel[i].equals("end of input variable"))){
         s4 = variablel[i];
         i1=0;
         Brkwhile:while(i1<=lookupvar.length-1){
         j1=1;
         if(lookupvar[i1][j1] != null){
         if(lookupvar[i1][j1].equals(s4)){
              s3 = lookupvar[i1][0];
              break Brkwhile;
         i1=i1+1;
    //ifirst.varNum = varnumber;
    s5 = 0;
    s6 = null;
    ifirst= new iList(s3,s4, s5, s6);
    ivarList.add(ifirst);
    System.out.println(s3+"     "+s4+"     "+s5+"     "+s6);
    i=i+1;
    i = i + 1;
    System.out.println("input list finished ");
    while(!(variablel[i].equals("end of output variable"))){
         s4 = variablel[i];
         i1=0;
         j1=1;
         Brkwhile:while(lookupvar[i1][j1] != null){
              if(lookupvar[i1][j1].equals(s4)){
              s3 = lookupvar[i1][0];
              break Brkwhile;
         i1=i1+1;
         s5 = 0;
         s6 = null;
         ofirst= new oList(s3,s4, s5, s6);
         ovarList.add(ofirst);
         System.out.println(s3+"     "+s4+"     "+s5+"     "+s6);
         i=i+1;
         llfirst = new lipsList(s1, s2, ivarList, ovarList);
         list.add(llfirst);
         System.out.println("output list finished ");
         i=i+1;
         catch (NullPointerException ne){
         catch (Exception d){}
    public int isitOK(reqPacket sndNodetail)
         throws RemoteException{
         String nodnum = sndNodetail.srcNum;
         String varnum = sndNodetail.varNum;
         int status = 0;
         llfirst = list.getFirst();
         try{mainbegin:while (llfirst != null){
              if((llfirst.nodeNum).equals(nodnum)){
              ofirst = ovarList.getFirst();
              while(ofirst != null){
                   if((ofirst.varNum).equals(varnum)){
                   if(ofirst.varVal==null){
                   status = 1;
                   break mainbegin;
         ofirst = ofirst.next;
         llfirst = llfirst.next;
         catch (NullPointerException nl){}
         return status;
    public int senData(dataPacket sendToRTS)
         throws RemoteException{
    dataPacket datDetail = sendToRTS;
    String nnum, vnum,typename, dval;
    String dtype = "";
    nnum = datDetail.nodeNum;
    vnum = datDetail.varNum;
    typename = datDetail.dataType;
    dval = String.valueOf(datDetail.dataVal);
    String [][] tempdrive, varnametype;
    int status =0;
    System.out.println("data received is from node " nnum " is "+ dval+"var num " +vnum);
    status =0;
    try{
    //DriverMatrix_mthds drive = new DriverMatrix_mthds();
    drive.VarTypeArray();
    drive.Variablelist();
    drive.NodeOrigin();
    drive.nodeInput();
    drive.numOfnodes();
    drive.noOfVariables();
    String[][] lookupvar = drive.novarType();
    drive.varNameType();
    drive.nodeNumName();
    drive.driverMat();
    tempdrive = drive.driverMat();
    String varname="";
    int i,j;
    //with the recived var name get the var num
    for(i=0; i<=lookupvar.length-1; i++){
         j=0;
         if(lookupvar[i][j] != null){
              if(lookupvar[i][j].equals(typename)){
                   dtype = lookupvar[i][1];
         }//varname is moved to dtype n used for checking
         for(i=0; i<=tempdrive.length-1; i++){j=0;
         if (tempdrive[i][j] != null){
         if (tempdrive[i][0].equals(vnum)){
              if (tempdrive[i][1].equals(nnum)){
              if(tempdrive[i][2].equals(dtype)){
              status = 1;
         }//System.out.println("received data " vnum " "+ nnum +" " + dtype +" "+dval);// after checking status if the status is 1 then set the counter n olist// to no of times the value has to be ditributed
    int Ccount =0;
    //opchannel = llfirst.olist;
    try{
         System.out.println("status"+status);
         if (status == 1){
              llfirst = list.getFirst();
         mainWhile: while (llfirst != null){
              if((llfirst.nodeNum).equals(nnum)){
                   ofirst = ovarList.getFirst();
                   while(ofirst != null){
                   if((ofirst.varNum).equals(vnum)){
                        ofirst.varVal =dval;
                        //setting the counter for the varname
                        //check driver matrix fr the no of occurances
                   for(i=0; i<=tempdrive.length-1; i++){
                   j=0;
                   if (tempdrive[i][j] != null){
                        if (tempdrive[i][0].equals(vnum)){
                        for(j= j+3;j<=tempdrive.length-1;j++){
                        if(tempdrive[i][j] != null){
                        if(tempdrive[i][j].equals("1")){
                        Ccount = Ccount + 1;
    System.out.println("count"+Ccount);
    ofirst.counter = Ccount;
    ofirst.varNum = vnum;for(i=0; i<=lookupvar.length-1; i++){
    for(j=0; j<=2; j++){
         if(lookupvar[i][j] != null){
         if(lookupvar[i][j].equals(vnum)){
              varname = lookupvar[i][1];
         ofirst.varName = varname;
         Ccount=0;
         break mainWhile;
         ofirst = ofirst.next;
         llfirst = llfirst.next;
         catch(NullPointerException s){}
    /*use the vnum in the driver matrix and find out the nodes to which this variable
    *has been sent as input , i mean destination nodes..
    *find the node numbers ..knowing the node numbers parse through data structure
    and set the input values to value and status 1./
    llfirst = list.getFirst();
    while(llfirst != null){
         ifirst = llfirst.ilist.getFirst();
         while(ifirst != null){
              if (ifirst.varNum.equals(vnum)){
              ifirst.varStat = 1;
              ifirst.varVal = dval;
              //     System.out.println("nodenum "+llfirst.nodeNum+" varval     " + ifirst.varVal +"     stat "+ifirst.varStat+" vnum " + ifirst.varNum);
         ifirst=ifirst.next;
         llfirst=llfirst.next;
         catch (Exception e){};
         return status;
    public int isinputAvail(reqPacket inputReq)
         throws RemoteException{
         String srcnum = inputReq.srcNum;
         String varnum = inputReq.varNum;
         int availstatus =0;
         llfirst = list.getFirst();
         //System.out.println("llfirst.nodeNum     "+ llfirst.nodeNum);
         whileloop:while (llfirst != null){
              if((llfirst.nodeNum).equals(srcnum)){
              ifirst = llfirst.ilist.getFirst();
              breakloop: while(ifirst != null){
              //System.out.println("var num " + varnum + "     " + "status outside" + ifirst.varStat);
              if((ifirst.varNum).equals(varnum)){
              if (ifirst.varStat == 1){
                   availstatus = 1;
                   ifirst.varStat = 0;
                   // System.out.println("var num " + varnum + "     " + "status" + availstatus);
                   break whileloop;
         ifirst = ifirst.next;
         llfirst = llfirst.next;
         //System.out.println("var num " + varnum + "     " + "status" + availstatus);
         return availstatus;
    public dataPacket senDatatoNode(reqPacket sendFromRTS)
         throws RemoteException {
         String nnum, vnum, dtype, dval;
         //nnum = "";
         dtype="";
         //opchannel = llfirst.olist;
         //     ipchannel = llfirst.ilist;
         reqPacket sendfromrts = sendFromRTS;
         nnum = sendfromrts.srcNum;
         vnum = sendfromrts.varNum;
         //     dtype = sendFromRTS.dataType;
         dval = "";
         int ctrchk=0;
         try{
         //send data to process node n reduce the counter by 1
         llfirst = list.getFirst();
              mainWhile: while (llfirst != null){
              if((llfirst.nodeNum).equals(nnum)){
              ofirst = llfirst.olist.getFirst();
         whileofirst: while(ofirst != null){
              if((ofirst.varNum).equals(vnum)){
              dval = ofirst.varVal;
              ofirst.counter = ofirst.counter - 1;
              //     System.out.println(ofirst.counter);
              ctrchk=ofirst.counter;
              break whileofirst;
         ofirst = ofirst.next;
    //set the status of respective input channel to 0 as data has been sent
         ifirst = llfirst.ilist.getFirst();
         if(ctrchk == 0){
         whileifirst: while(ifirst != null){
              if((ifirst.varNum).equals(vnum)){
              //ifirst.varVal = dval;
              ifirst.varStat =0;
              break whileifirst;
         llfirst = llfirst.next;
         //System.out.println(llfirst);
         catch(NullPointerException s){}
    //find type
    try{
         DriverMatrix_mthds driver = new DriverMatrix_mthds();
         driver.VarTypeArray();
         driver.Variablelist();
         driver.NodeOrigin();
         driver.nodeInput();
         driver.numOfnodes();
         driver.noOfVariables();
         driver.novarType()     ;
         String[][] lookupvar = driver.varNameType();
         int i, j;
         String varNum = vnum;
         for(i=0; i<=lookupvar.length-1; i++){
              j=0;
              if(lookupvar[i][j] != null){
              if(lookupvar[i][j].equals(vnum)){
              dtype = lookupvar[i][2];
         catch (Exception d){}
         dataPacket retpac = new dataPacket(nnum, vnum, dtype, dval);
         System.out.println("msg sent "+ nnum +"     " + vnum+" "+ dtype+"     "+ dval);
         return retpac;
    public String findnodeName(String nodeNum)
         throws RemoteException{
    String nnum = nodeNum;
    llfirst = list.getFirst();
    while (llfirst != null){
         if((llfirst.nodeNum).equals(nnum)){
         return llfirst.nodeName;
         llfirst = llfirst.next;
         System.out.println("node Number does not match with the list of node numbers generated..try again");
         return null;
    //find the nodenum given the node name
    public String findnodenum(String nodename)
         throws RemoteException{
         String nodenumber ="";
         String nodname = nodename;
         try{DriverMatrix_mthds driver = new DriverMatrix_mthds();
         driver.VarTypeArray();
         driver.Variablelist();
         driver.NodeOrigin();
         driver.nodeInput();
         driver.numOfnodes();
         driver.noOfVariables();
         driver.novarType()     ;
         driver.varNameType();
         String[][] lookupnode = driver.nodeNumName();
         int i, j;
         for(i=0; i<=lookupnode.length-1; i++){
         for(j=0; j<=2; j++){
              if(lookupnode[i][j] != null){
              if(lookupnode[i][j].equals(nodname)){
                   nodenumber = lookupnode[i][2];
         catch (Exception d){}
         return nodenumber;
    public String findvarnum(String variablename)
         throws RemoteException{
         String varnumber = "";
         try{
         DriverMatrix_mthds driver = new DriverMatrix_mthds();
         driver.VarTypeArray();
         driver.Variablelist();
         driver.NodeOrigin();
         driver.nodeInput();
         driver.numOfnodes();
         driver.noOfVariables();
         driver.novarType()     ;
         String[][] lookupvar = driver.varNameType();
         int i, j;
         String varname = variablename;
         for(i=0; i<=lookupvar.length-1; i++){
         for(j=0; j<=2; j++){
              if(lookupvar[i][j] != null){
              if(lookupvar[i][j].equals(varname)){
                   varnumber = lookupvar[i][0];
    catch (Exception d){}
    return varnumber;
    public String findvartype(String varname)
         throws RemoteException{
         String vartype = "";
         try{
         DriverMatrix_mthds driver = new DriverMatrix_mthds();
         driver.VarTypeArray();
         driver.Variablelist();
         driver.NodeOrigin();
         driver.nodeInput();
         driver.numOfnodes();
         driver.noOfVariables();
         driver.novarType();
         String[][] lookupvar = driver.varNameType();
         int i, j;
         String varName = varname;
         for(i=0; i<=lookupvar.length-1; i++){
         for(j=0; j<=2; j++){
              if(lookupvar[i][j] != null){
              if(lookupvar[i][j].equals(varName)){
                   vartype = lookupvar[i][2];
    catch (Exception d){}
    return vartype;
    public String findtypenum(String vartype){
    String varnum = "";int i;
    try{
         DriverMatrix_mthds driver = new DriverMatrix_mthds();
         driver.VarTypeArray();
         driver.Variablelist();
         driver.NodeOrigin();
         driver.nodeInput();
         driver.numOfnodes();
         driver.noOfVariables();
         String varNum[][] =      driver.novarType()     ;
         String varType = vartype;
         for(i=0; i<=9-1; i++){
              if(varNum[i][0] != null){
              if(varNum[i][0].equals(varType)){
                   varnum = varNum[i][1];
    catch (Exception d){}
    return vartype;
    //return input variable list
    public String[] inoutchanlist(String nodenum, String nodenam)
         throws RemoteException{
    try{
         DriverMatrix_mthds drive = new DriverMatrix_mthds();
         String[] varLIST = drive.Variablelist();
         int i=0;int j;
         while(varLIST[i]!=null){
              i=i+1;
         int arrlength = i;
         inoutChan = new String[arrlength];
         i=0; j=0;
         WHILELOOP:
         while(!(varLIST[i].equals("end of file"))){
         while(varLIST[i].equals(nodenum)){
              i=i+1;
              while(varLIST[i].equals(nodenam)){
                   i=i+1;
                   while(!(varLIST[i].equals("end of input variable"))){
                        inoutChan[j] = varLIST[i];
                        i=i+1;
                        j=j+1;
              System.out.println("endofinput");
              inoutChan[j]="endofinchan";
              j=j+1;
              i=i+1;
              while(!(varLIST[i].equals("end of output variable"))){
         inoutChan[j] = varLIST[i];
         i=i+1;
         j=j+1;
         System.out.println("endofoutput");
         inoutChan[j]="endofoutchan";
         break WHILELOOP;
         i=i+1;
         arrlength =j;
         for(j=0; j<=arrlength-1; j++){
         System.out.println(inoutChan[j]);
         catch (Exception e){}
         return inoutChan;
    public String[] inchannel(String[] inoutChan) throws RemoteException{
    int count=0;int i=0, j=0;
    System.out.println("entered");
    while(inoutChan[count]!=null){
         System.out.println(count + " " +inoutChan[count]);
         count=count+1;
         inChan = new String[count];
         while(!(inoutChan[i].equals("endofinchan"))){
         inChan[j] =inoutChan[i];
         j=j+1; i=i+1;
    return inChan;
    public String[] outchannel(String[] inoutChan) throws RemoteException{
    int count=0;int i=0, j=0;
    System.out.println("entered");
    while(inoutChan[count]!=null){
         System.out.println(count + " " +inoutChan[count]);
         count=count+1;
         outChan = new String[count+1];
         while(!(inoutChan[i].equals("endofinchan"))){
              i=i+1;
         i=i+1;
         while(!(inoutChan[i].equals("endofoutchan"))){
              outChan[j] =inoutChan[i];
              j=j+1; i=i+1;
         return outChan;
    public String[] invarChan(String nodename, int guardno)throws RemoteException{
    try{
    DriverMatrix_mthds drive = new DriverMatrix_mthds();
    invarLIST = drive.invarlist();
    int i=0;int j;
    while(invarLIST[i]!=null){
         i=i+1;
         int arrlength = i;
         inVAR = new String[arrlength];
         i=0; j=0;
              WHILELOOP: while(!(invarLIST[i].equals("end of file"))){
                   if (invarLIST[i].equals(nodename)){
         i=i+1;
         while(!(invarLIST[i].equals(nodename+String.valueOf(guardno)))){
         i=i+1;}
         i=i+1;
         while(!(invarLIST[i].equals("endofguard"))){
         System.out.println(invarLIST[i]);inVAR[j]=invarLIST[i]; i=i+1; j=j+1;}
         break WHILELOOP;}
         i=i+1;}
    }catch (Exception d){}
    return inVAR;
    public String[] outvarChan(String nodename, int guardcount)throws RemoteException{
         try{
         DriverMatrix_mthds drive = new DriverMatrix_mthds();
         outvarLIST = drive.outvarlist();
         int i=0;int j;
         while(outvarLIST[i]!=null){
              i=i+1;
         int arrlength = i;
         outVAR = new String[arrlength];
         i=0; j=0;
         WHILELOOP: while(!(outvarLIST[i].equals("end of file"))){
              if (outvarLIST[i].equals(nodename)){
                   i=i+1;
                   while(!(outvarLIST[i].equals(nodename+String.valueOf(guardcount)+"guard"))){
                        i=i+1;}
              i=i+1;
              while(!(outvarLIST[i].equals("end guard"))){
              System.out.println(outvarLIST[i]);outVAR[j]=outvarLIST[i]; i=i+1; j=j+1;}
              break WHILELOOP;}
         i=i+1;}
    }catch (Exception d){}
    return outVAR;
    private static Boolean start;
    private static Boolean tstart;
    public void sendstart(Boolean start) throws RemoteException {
         tstart = start;
    public Boolean getstart() throws RemoteException{
         return tstart;
    private static Boolean done;
    private static Boolean tdone;
    public void senddone(Boolean done) throws RemoteException {
         tdone = done;
    public Boolean getdone() throws RemoteException{
         return tdone;
    private static Boolean vac_busy1;
    private static Boolean tvac_busy1;
    public void sendvac_busy1(Boolean vac_busy1) throws RemoteException {
         tvac_busy1 = vac_busy1;
    public Boolean getvac_busy1() throws RemoteException{
         return tvac_busy1;
    private static int cus1_rit1;
    private static int tcus1_rit1;
    public void sendcus1_rit1(int cus1_rit1) throws RemoteException {
         tcus1_rit1 = cus1_rit1;
    public int getcus1_rit1() throws RemoteException{
         return tcus1_rit1;
    private static int cus1_rit2;
    private static int tcus1_rit2;
    public void sendcus1_rit2(int cus1_rit2) throws RemoteException {
         tcus1_rit2 = cus1_rit2;
    public int getcus1_rit2() throws RemoteException{
         return tcus1_rit2;
    private static int cus1_rit3;
    private static int tcus1_rit3;
    public void sendcus1_rit3(int cus1_rit3) throws RemoteException {
         tcus1_rit3 = cus1_rit3;
    public int getcus1_rit3() throws RemoteException{
         return tcus1_rit3;
    private static int cus1_it1;
    private static int tcus1_it1;
    public void sendcus1_it1(int cus1_it1) throws RemoteException {
         tcus1_it1 = cus1_it1;
    public int getcus1_it1() throws RemoteException{
         return tcus1_it1;
    private static int cus1_it2;
    private static int tcus1_it2;
    public void sendcus1_it2(int cus1_it2) throws RemoteException {
         tcus1_it2 = cus1_it2;
    public int getcus1_it2() throws RemoteException{
         return tcus1_it2;
    private static int cus1_it3;
    private static int tcus1_it3;
    public void sendcus1_it3(int cus1_it3) throws RemoteException {
         tcus1_it3 = cus1_it3;
    public int getcus1_it3() throws RemoteException{
         return tcus1_it3;
    private static int stkit_11;
    private static int tstkit_11;
    public void sendstkit_11(int stkit_11) throws RemoteException {
         tstkit_11 = stkit_11;
    public int getstkit_11() throws RemoteException{
         return tstkit_11;
    private static int stkit_12;
    private static int tstkit_12;
    public void sendstkit_12(int stkit_12) throws RemoteException {
         tstkit_12 = stkit_12;
    public int getstkit_12() throws RemoteException{
         return tstkit_12;
    private static int stkit_13;
    private static int tstkit_13;
    public void sendstkit_13(int stkit_13) throws RemoteException {
         tstkit_13 = stkit_13;
    public int getstkit_13() throws RemoteException{
         return tstkit_13;
    private static int c1_it1;
    private static int tc1_it1;
    public void sendc1_it1(int c1_it1) throws RemoteException {
         tc1_it1 = c1_it1;
    public int getc1_it1() throws RemoteException{
         return tc1_it1;
    private static int c1_it2;
    private static int tc1_it2;
    public void sendc1_it2(int c1_it2) throws RemoteException {
         tc1_it2 = c1_it2;
    public int getc1_it2() throws RemoteException{
         return tc1_it2;
    private static int c1_it3;
    private static int tc1_it3;
    public void sendc1_it3(int c1_it3) throws RemoteException {
         tc1_it3 = c1_it3;
    public int getc1_it3() throws RemoteException{
         return tc1_it3;
    //endoffile

  • Need help w/ wierd problem maybe caused by RMI/sockets

    Hi.
    I'm having a potential problem at a customer site which
    has me completely baffled and with which I could do with
    some help.
    I've written and deployed at the customer site an Client/
    Server application, developed using RMI. The problem occurs
    on the server side.
    I've implemented my own SocketFactory and am restricting
    the sockets to ports 8091 and 8091 - through the SocketFactory
    and through the constructor of java.rmi.server.UnicastRemoteObject.
    The server is waiting for incoming commections. The DGC
    regularly does maintenance and garbage collection, triggering
    my SocketFactory. Server machine is Windows 2000. The server
    machine has local server ports 8090 and 8091 in LISTENING
    state (on 0.0.0.0:8090 and 0.0.0.0:8091).
    The server, machine A, is waiting for incoming connections from
    the client application, on machine B, which is not running. On the
    same network segment are machines C, D and E (all Linux machines),
    on which NONE of my software is running, and which should have
    NOTHING to do with my system. These machines are communicating
    amongst themselves, but not with machine A.
    The customer claims (I'm not on-site, so I can't check), that
    after a random time of running my server application 24/7 (the
    first time after about a week, the second time after only 3 hours),
    machines C, D and E were no longer able to exchange data. As soon
    as my server application on machine A is aborted, systems C,
    D and E are again able to exchange data - immediately.
    What I don't understand is:
    How is it possible, that an RMI server application, which
    has opened sockets, accept()s them, has the open sockets
    in LISTENING state, but is not actively sending data,
    IN ANY WAY influences the traffic on the rest of the subnet?
    Do opened Sockets in the accept() state send ANY form of
    traffic over the network?
    Is there any way I can influence other machines on the
    network, simply by opening a bunch of inbound sockets? To
    the best of my understanding of networks and TCP/IP there
    should be no way to do that. Or am I wrong?
    Again, I'd appreciate any help or pointer or even wild
    theory related to this problem.
    Thanks,
    Daniel

    For starters, why don't you try changing the ports you are using?

  • Unable to get Rmi program working. Help plz - urgent.

    Any help to get this problem resolved would be of help.
    I get the error as below:
    D:\test\nt>java Client
    Server
    Client exception: Error marshaling transport header; nested exception is:
    javax.net.ssl.SSLException: untrusted server cert chain
    java.rmi.MarshalException: Error marshaling transport header; nested exception is:
    javax.net.ssl.SSLException: untrusted server cert chain
    javax.net.ssl.SSLException: untrusted server cert chain
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write([DashoPro-V1.2-120198])
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:76)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:134)
    at java.io.DataOutputStream.flush(DataOutputStream.java:108)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:207)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:178)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:87)
    at Server_Stub.passArgs(Unknown Source)
    at Client.main(Client.java, Compiled Code)
    the server was invokde as:
    D:\test\nt>java -Djava.rmi.server.codebase="file:/d:/test" -Djava.policy=d:/test/policy Server a b c
    Server bound in registry
    where policy had allpermission
    The server program is given as below:
    import java.net.InetAddress;
    import java.rmi.Naming;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.rmi.RemoteException;
    import java.rmi.RMISecurityManager;
    import java.rmi.server.UnicastRemoteObject;
    public class Server extends UnicastRemoteObject implements Message
         private static String[] args;
         public Server() throws RemoteException
              // super();     
              super(0, new RMISSLClientSocketFactory(),
                   new RMISSLServerSocketFactory());
         public String[] passArgs() {
              System.out.println(args[0]);
              System.out.println(args[1]);
              System.out.println(args[2]);
              System.out.println(args.length);
              System.out.println();
              return args;
         public static void main(String a[])
              // Create and install a security manager
              if (System.getSecurityManager() == null)
                   System.setSecurityManager(new RMISecurityManager());
              args=a;
              try
                   Server obj = new Server();
                   // Bind this object instance to the name "Server"
                   Registry r = LocateRegistry.createRegistry(4646);
                   r.rebind("Server", obj);
                   System.out.println("Server bound in registry");
              } catch (Exception e) {
                   System.out.println("Server err: " + e.getMessage());
                   e.printStackTrace();
    The RMISSLServerSocketFactory class is as below:
    import java.io.*;
    import java.net.*;
    import java.rmi.server.*;
    import javax.net.ssl.*;
    import java.security.KeyStore;
    import javax.net.*;
    import javax.net.ssl.*;
    import javax.security.cert.X509Certificate;
    import com.sun.net.ssl.*;
    public class RMISSLServerSocketFactory implements RMIServerSocketFactory, Serializable
         public ServerSocket createServerSocket(int port)
              throws IOException     
              SSLServerSocketFactory ssf = null;
              try {
                   // set up key manager to do server authentication
                   SSLContext ctx;
                   KeyManagerFactory kmf;
                   KeyStore ks;
                   char[] passphrase = "passphrase".toCharArray();
                   ctx = SSLContext.getInstance("TLS");
                   kmf = KeyManagerFactory.getInstance("SunX509");
                   ks = KeyStore.getInstance("JKS");
                   ks.load(new FileInputStream("testkeys"), passphrase);
                   kmf.init(ks, passphrase);
                   ctx.init(kmf.getKeyManagers(), null, null);
                   ssf = ctx.getServerSocketFactory();
              } catch (Exception e)
                   e.printStackTrace();
                   return ssf.createServerSocket(port);
    The RMIClientSocketFactory is as below:
    import java.io.*;
    import java.net.*;
    import java.rmi.server.*;
    import javax.net.ssl.*;
    public class RMISSLClientSocketFactory     implements RMIClientSocketFactory, Serializable
         public Socket createSocket(String host, int port)
              throws IOException
              SSLSocketFactory factory =(SSLSocketFactory)SSLSocketFactory.getDefault();
              SSLSocket socket = (SSLSocket)factory.createSocket(host, port);
                   return socket;
    And finally the client program is :
    import java.net.InetAddress;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.rmi.RemoteException;
    public class Client
         public static void main(String args[])
              try
                   // "obj" is the identifier that we'll use to refer
                   // to the remote object that implements the "Hello"
                   // interface
                   Message obj = null;
                   Registry r = LocateRegistry.getRegistry(InetAddress.getLocalHost().getHostName(),4646);
                   obj = (Message)r.lookup("Server");
                   String[] s = r.list();
                   for(int i = 0; i < s.length; i++)
                        System.out.println(s);
                   String[] arg = null;
                   System.out.println(obj.passArgs());
                   arg = obj.passArgs();
                   System.out.println(arg[0]+"\n"+arg[1]+"\n"+arg[2]+"\n");
              } catch (Exception e) {
                   System.out.println("Client exception: " + e.getMessage());
                   e.printStackTrace();
    The Message interface has the code:
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface Message extends Remote
         String[] passArgs() throws RemoteException;
    Plz. help. Urgent.
    Regards,
    LioneL

    hi Lionel,
    have u got the problem solved ?
    actually i need ur help regarding RMI - SSL
    do u have RMI - SSL prototype or sample codings,
    i want to know how to implement SSL in RMI
    looking for ur reply
    -shafeeq

  • Please help with an RMI problem

    Hi,
    This is probably a really simple problem which i can't spot, but i have the folloing 'HelloWorld' RMI program:
    The Client Program:
    import java.rmi.*;
    public class HelloClient {
         public static void main(String args[]) {
              if(System.getSecurityManager() == null) {
                   System.setSecurityManager(new RMISecurityManager());
              try {
                   HelloInterface obj = (HelloInterface)Naming.lookup("/HelloServer");
                   String message = obj.sayHello();
                   System.out.println(message);
                   Thread.sleep(10000);
              } catch (Exception e) {
                   System.out.println("HelloClient exception: " + e);
    }The Remote Interface:
    public interface HelloInterface extends java.rmi.Remote {
         public String sayHello() throws java.rmi.RemoteException;
    }The Server Program:
    import java.io.*;
    import java.rmi.*;
    import java.rmi.server.*;
    import java.util.Date;
    public class HelloServer extends UnicastRemoteObject implements HelloInterface {
         public HelloServer() throws RemoteException {
              super();
         public String sayHello() throws RemoteException {
              return "Hello World, the current system time is " + new Date();
    }And finally the class which binds the object to the registery:
    import java.rmi.*;
    public class RegisterIt {
         public static void main(String args[]) {
              try {
                   HelloServer obj = new HelloServer();
                   System.out.println("Object instantiated: " + obj);
                   Naming.rebind("/HelloServer", obj);
                   System.out.println("HelloServer bound to registery");
              } catch (Exception e) {
                   System.out.println(e);
    }Now, this program works fine on my computer at home(XP!!!!!) but when i try to run it on the computers in college which run NT, it comes up with the following exceptions when i try to run RegisterIt:
    Java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    Java.lang.ClassNotFoundException: HelloServer_StubThis is saying that it cannot find the stub which is generated, but i use the folloing .bat file to load up the program:
    echo Creating remote object skelton classes....
    rmic -d . HelloServer
    start rmiregistry -J-Djava.security.policy=test.policy
    start java RegisterIt
    start java -Djava.security.policy=test.policy HelloClientThe stub is definitely created(it worked at home and i have checked in the directory and there are clearly the files HelloServer_Stub.class and HelloServer_Skel.class). The PATH is set correctly otherwise the registery would not be able to run correctly etc and therefore i am completely stuck as to why it doesn't work.
    Please help as it is very important for me.
    Many Thanks
    Cath

    I did not have any problem with Windows 2000 at all but only with Windows XP (and to think XP is a 2000 hybrid!).
    I have the same error: a ClassNotFoundException on the stub file.
    Any help will be appreciated. Thanks.

  • A problem in RMI with JSP..pls help

    RMI with Java is working fine,but...
    1. I am facing a problem when i use RMI with JSP..its throwing an exception during "Naming.lookup"..here is my code snippet:
    // i have stored the ServerInf and other classes in a package and i have imported it in the jsp code....object ref is getting created but lookup is throwing an exception...thoguh RMI registry is working(started)
    <%
    try {
    ServerInf ref = (ServerInf)Naming.lookup("rmi://localhost:1098/Server_bind");
    catch (Exception ex) {
    ex.printStackTrace();
    %>
    Pls tel me the cause.
    2. If i try to use RMI with Servlet and JSP, then wen the JSP runs then, it simply calls the servlet file and displayes a lonk to it instead of executing the servlet class. pls help me with this too...below is the invoking statement:
    <form method=post action='http://localhost:8080/servlet/MyRMIservlet'>
    hello <input type=submit value=submit>

    And the exception and error message is.....

Maybe you are looking for

  • PR Price Adopted to PO for service item

    We are using idocs which uses BAPI_PO_CREATE1 to load the legacy PO's into ECC. Even though we supply the PO Price which is different than the PR Price for service item, the price is still adopted from PR which we don't want. I checked ML91 and there

  • Problem when creating multiple traffic lights column in SALV...

    Hello Experts, I am using ALV display using the SALV(factory) method. My problem is, only the last excception column shows. I making 3 exception columns. Below is my code: gt_output[] = im_output[].     TRY.         cl_salv_table=>factory(          

  • Urgent: runtime error problem

    hi, iam working on development server and when i run a tcode and aftere dat when i press f1 for help on any field den a runtime error occurs. saying dat :-   The current ABAP/4 program terminated due to   an internal error in the database interface.

  • Just Upgraded to 3.1.2 - doSubmit is not defined.

    I just upgraded to the latest XE by running the download. I am getting this error on the browser when I try to login : Error: doSubmit is not defined Source File: http://127.0.0.1:8080/apex/f?p=4550:1:1915389911065507 Line: 1 Any suggestions? -SJ

  • Help with running a QTVR with ASP?

    Hi! Hope somebody may be able to help. I've had a request from a client to shoot and create a number of QTVR panoramas for their website. The website operates using ASP which I have had no experience of at all. Could anyone know if this is firsly pos