0 Replies Latest reply on Jun 10, 2005 5:29 AM by A B

    Problem creating standalone client

    A B Newbie


      I am trying to create a standalone client, which accesses a JBoss server using a Session bean. In my simple example, I would basically try to use a Session bean's network-capabilities to call some method on the server and get the result back to the client.

      I started with the Fibonacci tutorial found at JBossIDE. After some fiddling around, I got a working servlet example. So I tried to create a simple standalone client, which does the same as the servlet: connect to the Session bean, call a method and display the result. All this from the commandline, so I can use System.out.writeln() for output.

      This standalone client works great when I start it on the same machine where also the JBoss server is running.

      Starting it on a different machine, however, does not work. It seems the program always tries to connect to localhost (, but of course there is no JBoss server answering.

      Using tcpdump, I found that the program is in fact connecting to the remote JBoss server first, and some data is exchanged, but afterwards it tries to connect to localhost.

      Maybe I have a conceptual problem here: can I lookup a Session bean on a remote server and use it, without having a JBoss server also running on the local machine?

      I would be glad for any hint, as I spent more that a day now trying to find what's wrong here, and I am sure it is only a very small detail I am missing.


      Christoph Jäger

      P.S.: Just for completeness, I am using JBoss 4.0.1sp1 on a Fedora Linux machine, Java5.0, and the machine I am trying to run my client from is a Windows machine, also Java5.0.

      Here is the source code of my client program:

      package tutorial.text;
      import java.io.IOException;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.rmi.PortableRemoteObject;
      import tutorial.interfaces.Fibo;
      import tutorial.interfaces.FiboHome;
      public class ComputeMain {
       private FiboHome home;
       public static void main(String[] args) throws IOException {
       ComputeMain main = new ComputeMain();
       public ComputeMain() {
       try {
       Context context = new InitialContext();
       Object ref = context.lookup("ejb/Fibo");
       home = (FiboHome) PortableRemoteObject.narrow(ref, FiboHome.class);
       } catch (Exception e) {
       System.err.println("Lookup of java:/comp/env/ failed");
       protected void run(int limit) {
       double[] result=null;
       try {
       Fibo bean = home.create();
       result = bean.compute(limit);
       } catch (Exception e) {
       System.err.println("Call of bean.compute() failed");
       System.out.println("got result:");
       for (int i=0;i<result.length;i++)
       System.out.println(i+": "+result);

      and my jndi.properties file: