How to call remote ejb deployed on jboss?


EJB programming & troubleshooting: How to call remote ejb deployed on jboss?

  1. How to call remote ejb deployed on jboss? (11 messages)

    I donot know why my stand-alone client can not lookup
    ejb deployed on another machine. The app server is JBOSS.

    Test code is :

    Hashtable environment = new Hashtable();
                environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                environment.put(Context.PROVIDER_URL, "jnp://"); // remote machine IP
                InitialContext context = new InitialContext(environment);
                Object obj = context.lookup("MyBean"); //ejb-name
                System.out.println("-->> lookup object successfully");


    Exception is :

         [java] javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connec
    tion refused to host:; nested exception is:
         [java] Connection refused: connect]
         [java] at org.jnp.interfaces.NamingContext.lookup(
         [java] at org.jnp.interfaces.NamingContext.lookup(
         [java] at javax.naming.InitialContext.lookup(
         [java] at vic.test.jboss.TestDS.main(Unknown Source)
         [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [java] at sun.reflect.NativeMethodAccessorImpl.invoke(
         [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(


    Can you give me some advises? Thanks!

    Threaded Messages (11)

  2. How to call remote ejb deployed on jboss?[ Go to top ]

    Double check if the RMI port is 1099 or not. Typically ConnectionException happens if the port is not right or the server is not started on that port.

  3. How to call remote ejb deployed on jboss?[ Go to top ]

    thanks, i resolved this problem.
    There is something wrong with my linux server configuration
  4. How to call remote ejb deployed on jboss?[ Go to top ]

    Do you mind sharing with us how did you resolve this problem ? I seem to have the same problem with JBoss installation on Linux. Thank you very much.
  5. Same error[ Go to top ]

    It seems that you solved you problem, can you share what you did ?
    I am getting the same error and already checked that the jnp port is 1099.
  6. host entries[ Go to top ]

    This problem will mainly happen on redhar based linux distros (not suse etc thou, only those directly based on RH like centos etc)
    You need to update your hosts file. By default you will have an entry for with your hostnames next to it like follows: myserver localhost localhost.localdomain

    you need to add a line for your local ip address also and then move your hostnames to it, leaving the localhost entries on like such: localhost localhost.localdomain myserver

    Then restart jboss. It will now bind to both and the 192 (or other) address allowing you to access it from remote machines.
  7. any other way?[ Go to top ]

    I am using the same solution currently. This holds good for Static IP configuration.

    Any solution to work with DHCP?
  8. DHCP[ Go to top ]

    The information in the thread

    could be useful in the case of DHCP.
  9. Hi, I had the same problem. Surfing in the web I found this information: By default JBossAS binds its services to localhost ( To enable remote access by binding JBoss services to a particular interface, simply run jboss with the -b option. Example: if your ip is, you must to start JBoss like: ./ -b192.168.22.14 or ./ --host= for windows: run.bat -b192.168.22.14 or run.bat --host= Good luck. Martti.
  10. This helped a lot[ Go to top ]

    This helped a lot. Thanks a lot Ramdas
  11. really helpfull[ Go to top ]

    Thanks buddy.

    Its really helpfull to me.

    Once again thank u very much.

  12. lookup[ Go to top ]

    Object obj = context.lookup("MyBean"); //ejb-name

    instead of using the above code, use the following code

    Object obj = context.lookup("MyBean/remote"); //ejb-name