Discussions

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://10.200.1.21:1099"); // 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: 127.0.0.1; nested exception is:
         [java] java.net.ConnectException: Connection refused: connect]
         [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:648)
         [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
         [java] at javax.naming.InitialContext.lookup(InitialContext.java:347)
         [java] at vic.test.jboss.TestDS.main(Unknown Source)
         [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
    :25)

        ......


    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.

    raghu
  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 127.0.0.1 with your hostnames next to it like follows:

    127.0.0.1 myserver.server.com 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 127.0.0.1 like such:

    127.0.0.1 localhost localhost.localdomain
    192.168.100.1 myserver.server.com myserver

    Then restart jboss. It will now bind to both 127.0.0.1 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 http://forum.java.sun.com/thread.jspa?forumID=58&tstart=0&threadID=288759&trange=15

    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 (127.0.0.1). To enable remote access by binding JBoss services to a particular interface, simply run jboss with the -b option. Example: if your ip is 192.168.22.14, you must to start JBoss like: ./run.sh -b192.168.22.14 or ./run.sh --host=192.168.22.14 for windows: run.bat -b192.168.22.14 or run.bat --host=192.168.22.14 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