Jump to content
Excelsior Forums
vh

JET and RMI

Recommended Posts

Hi all,

I'm to trying to compile a RMI Client/Server application with Excelsior JET.

By starting the server I become the following exception:

ServerImp.main:Connection refused to host: 127.0.0.1; nested exception is:

       java.net.ConnectException: Connection refused: connect

By compiling a server.jar and a client.jar, it runs very well.

I hope that someone could help me.

Here my code:

*****Server.java

package com.test;

import java.rmi.Remote;

import java.rmi.RemoteException;

public interface Server extends Remote

{

  String index(String text) throws RemoteException;

}

*****ServerImp.java

package com.test;

import java.rmi.Naming;

import java.rmi.RemoteException;

import java.rmi.registry.*;

import java.rmi.server.UnicastRemoteObject;

public class ServerImp

   extends UnicastRemoteObject implements Server

{

  public ServerImp() throws RemoteException

  {

     super();

  }

  public String index(String text)

  {

     return "function index:"+text;

  }

  public static void main(String[] args)

  {

     System.setSecurityManager(null);

     try

     {

        LocateRegistry.createRegistry(1099);

     }

     catch (Exception ex)

     {

     

     }

     try

     {

        ServerImp engine = new ServerImp();

        Naming.rebind("rmi://127.0.0.1/Server",engine);

     }

     catch (Exception ex)

     {

     }

  }

}

*****Client.java

package com.test;

import java.rmi.Naming;

public class Client

{

  public Client()

  {

     super();

  }

  public static void main(String args[])

  {

     System.setSecurityManager(null);

     Server server = (Server) Naming.lookup("//127.0.0.1/Server");

        System.out.println(server.index(":-)"));

     }

     catch (Exception ex)

     {

     }

  }

}

Share this post


Link to post
Share on other sites

1) Make sure that you truned JIT on

2) Empty catch clauses is not a good idea. If an exception is thrown, it is worth to print it, as it can give you usefule information about the reason of the problem

Share this post


Link to post
Share on other sites

Hi,

I try to compile it with the option 'Enable JIT Compiler'. It doesn't run.

Do you have another idea?

Share this post


Link to post
Share on other sites

Hi,

I've try to compile and start the Excelsion-sample 'RemoteCalculator'  located in %EXCELSIOR%/samples/RemoteCalculator

I compile it with the script 'build.bat'

Then, I try to start the Server with the script 'runServer'.

I become the following exception:

Oops! java.rmi.ConnectException: Connection refused to host: Localhost; nested exception is:

       java.net.ConnectException: Connection refused: connect

Stack trace:

java.rmi.ConnectException: Connection refused to host: Localhost; nested exception is:

       java.net.ConnectException: Connection refused: connect

Caused by: java.net.ConnectException: Connection refused: connect

I hope do you have an idea.

Thanks,

vh.

Share this post


Link to post
Share on other sites

Hi,

I've compiled it now directly with the jc Compiler( no GUI mode). It runs very well. I don't know why it doesn't run with the GUI.

VH.

Share this post


Link to post
Share on other sites

×