This discussion is archived
11 Replies Latest reply: May 31, 2011 10:18 PM by 581640 RSS

Can't access GF3.1 remote EJBs from standalone client

646423 Newbie
Currently Being Moderated
My project worked perfectly with GlassFish 3.0.1,
but with remote GlassFish 3.1 I can't lookup remote EJB-s from a standalone client.
If the GlassFish 3.1 is local, then I can lookup EJB-s.

The minimal Eclipse 3.6.2 workspace is available:
www.dopti.hu/~bboros/workspace_lookup_remote_ejb.zip

Architecture:
Debian server (192.168.0.202) with GlassFish 3.1
Ubuntu client
Eclipse 3.6.2 with the latest Oracle GlassFish plugin

There is one stateless session bean: SayHello.java
package hu.bb;
import javax.ejb.Stateless;
package hu.bb;

import javax.ejb.Stateless;


@Stateless
public class SayHello implements SayHelloRemote {


public SayHello() {
}

public String sayHello(String name) {
return "Hello " + name;
}
}

Remote interface:
package hu.bb;
import javax.ejb.Remote;

@Remote
public interface SayHelloRemote {

public String sayHello(String name);
}

The application client:
import javax.naming.InitialContext;
import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {
Main app = new Main();
try {
app.execute();
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error: " + e.getClass().getName() + " " + e.getMessage());
}
}

private void execute() throws Exception {
InitialContext ic = new InitialContext();
System.out.println("InitialContext created");

hu.bb.SayHelloRemote sh = null;
try {
String strBean = "java:global/SayHello/SayHello_ejb/SayHello!hu.bb.SayHelloRemote";
//String strBean = "java:global/SayHello/SayHello_ejb/SayHello";
//String strBean = "hu.bb.SayHello";
System.out.println("lookup : " + strBean);
sh = (hu.bb.SayHelloRemote)ic.lookup(strBean);
} catch (Exception e) {
throw new Exception("EJB lookup failure ", e);
}

// calling EJB
String strResult = sh.sayHello("Mr. Smith");

System.out.println(strResult);
JOptionPane.showMessageDialog(null, strResult);
}
}


The gf-client.jar is on the classpath.
If the GlassFish is on the same machine, the program runs correctly.

But if the GlassFish is on the remote 192.168.0.202 machine,
the InitialContext.lookup() does not return:
Thread.sleep(long) line: not available [native method]
TcpTimeoutsImpl$1.sleepTime() line: 158
CorbaContactInfoListIteratorImpl.next() line: 232
CorbaContactInfoListIteratorImpl.next() line: 69
CorbaClientDelegateImpl.request(Object, String, boolean) line: 213
CorbaClientDelegateImpl.is_a(Object, String) line: 393
CORBAObjectImpl(ObjectImpl)._is_a(String) line: 112
NamingContextHelper.narrow(Object) line: 69
SerialContext$ProviderCacheKey.getNameService() line: 1241
SerialContext.getRemoteProvider() line: 411
SerialContext.getProvider() line: 347
SerialContext.lookup(String, int) line: 504
SerialContext.lookup(String) line: 455
InitialContext.lookup(String) line: 392
Main.execute() line: 28
Main.main(String[]) line: 11


The VM arguments:
-Dorg.com.CORBA.ORBInitialHost=192.168.0.202

Please help, I don't know what is wrong.
Thank you

Edited by: user643420 on Mar 11, 2011 5:47 AM
  • 1. Re: Can't access remote EJBs (GF3.1)
    gimbal2 Guru
    Currently Being Moderated
    Check the Glassfish V3.1 environment; you may be running the web JEE profile in stead of the full profile. If I remember correctly remote EJBs are not supported by the web profile.

    In other words, make sure you used to proper download from this page:

    http://glassfish.java.net/downloads/3.1-final.html
  • 2. Re: Can't access remote EJBs (GF3.1)
    846391 Newbie
    Currently Being Moderated
    Thank you for your suggestion.

    I checked it again. It is the full profile installed.
    This is the row of the EJB container in the installed components page:
    glassfish-ejb     Application Servers     3.1-43     298KB     release.javaeesdk.oracle.com


    The deploy is successfully executed.
    (When the GlassFish 3.1 and the Application Client are on the same computer,
    everything is working.)
  • 3. Re: Can't access remote EJBs (GF3.1)
    gimbal2 Guru
    Currently Being Moderated
    Seeing the exception for the first time, it looks like a vague description of a simple connection timeout. So connection to the remote host is not working. That will not be in your code but in the environment; network settings, server config, whatever. It could be a firewall blocking traffic for example. It could be the remote host actively refusing the connection even.

    Sorry, there is not much more I can say about this other than look outside the code for the problem.
  • 4. Re: Can't access remote EJBs (GF3.1)
    846391 Newbie
    Currently Being Moderated
    I tried it with
    1) new installed GlassFish 3.1
    2) GlassFish 3.0.1 ugpgraded to GlassFish 3.1 with "pkg upgrde"
    3) GlassFish 3.0.1 upgraded to GlassFish 3.1 with "asupgrade"
    4) I tried the GlassFish 3.1 with orb-listener-1 (0.0.0.0)
    5) I tried the GlassFish 3.1 with orb-listener-1 (192.168.0.202)
    None of the above was successfull.


    The stack trace is not from an Exception.
    The program was stucked in InitialContext.lookup() and I pressed "suspend" in Eclipse debug perspective.

    Any help is appreciated.
  • 5. Re: Can't access remote EJBs (GF3.1)
    gimbal2 Guru
    Currently Being Moderated
    843388 wrote:
    I tried it with
    1) new installed GlassFish 3.1
    2) GlassFish 3.0.1 ugpgraded to GlassFish 3.1 with "pkg upgrde"
    3) GlassFish 3.0.1 upgraded to GlassFish 3.1 with "asupgrade"
    4) I tried the GlassFish 3.1 with orb-listener-1 (0.0.0.0)
    5) I tried the GlassFish 3.1 with orb-listener-1 (192.168.0.202)
    None of the above was successfull.


    The stack trace is not from an Exception.
    The program was stucked in InitialContext.lookup() and I pressed "suspend" in Eclipse debug perspective.

    Any help is appreciated.
    Nothing changes. If the lookup is "stuck", it cannot create a connection and you are waiting for a timeout.
  • 6. Re: Can't access remote EJBs (GF3.1)
    846391 Newbie
    Currently Being Moderated
    I have a local GlassFish 3.1 and a remote one.

    If the standalone client program
    (www.dopti.hu/~bboros/workspace_lookup_remote_ejb.zip)
    is started with "-Dorg.omg.CORBA.ORBInitialHost=192.168.1.106" VM argument,
    both the local and remote GlassFish should run.

    If one of them is not running the lookup() will not return successfully: either returns exceptions or does not return.

    Can you help me,
    Why does the org.omg.CORBA.ORBInitialHost requires the additional local GlassFish running ?

    Thank you.
  • 7. Re: Can't access GF3.1 remote EJBs from standalone client
    848351 Newbie
    Currently Being Moderated
    Did you change the port from the default? If so, you also have to specify it.

    Edited by: user10429597 on Mar 17, 2011 12:44 PM

    Edited by: user10429597 on Mar 17, 2011 12:46 PM
  • 8. Re: Can't access GF3.1 remote EJBs from standalone client
    846391 Newbie
    Currently Being Moderated
    The default ORB port is not changed. It is 3700.

    I tried the above linked small eclipse program in several machines
    with new installed GlassFish 3.1 and
    GlassFish 3.0.1 upgraded to GlassFish 3.1.
  • 9. Re: Can't access GF3.1 remote EJBs from standalone client
    581640 Newbie
    Currently Being Moderated
    Hi there, im having the same problem. Did you find the cause of the problem ?
  • 10. Re: Can't access GF3.1 remote EJBs from standalone client
    581640 Newbie
    Currently Being Moderated
    Hi again,
    I used wireshark to sniff packets between my client and server and realize that the client generated a "GIOP REQUEST" to the right server ( the remote one ) but the server gave it a
    "GIOP REPLY" with iiop::profile_host and component_data to 127.0.01 apparently making my client seek for the endpoint in the localhost.
    That explain why the client works if you run both remote and local servers.
    Could it be a bug in glassfish 3.1 ? Tomorrow I will conduct some tests with v3.0 and 2.1. Its alread 1:52am here....

    Link to [http://www.linuxrouter.com.br/iiop.png]

    Edited by: Lucas Nishimura on May 31, 2011 9:53 PM
  • 11. Re: Can't access GF3.1 remote EJBs from standalone client
    581640 Newbie
    Currently Being Moderated
    Found the solution here:
    oszhatife added a comment - 23/May/11 04:24 AM
    Thank you for your help.

    I followed the instructions from http://www.java.net/node/676636
    and changed "/etc/hosts" file:
    +1) commented out the "internal" IP addresses in the first two lines+
    +2) and added a the external IP address+

    +#127.0.0.1 localhost+
    +#127.0.1.1 lennyserver+
    +192.168.0.202 lennyserver+

    The following lines are desirable for IPv6 capable hosts
    +::1 localhost ip6-localhost ip6-loopback+
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    Now the InitialContext.lookup() can find the bean.

    I suggest this solution to be included in the documentation.

    from http://java.net/jira/browse/GLASSFISH-16314

    My /ets/hosts file had 2 entries for 127.0.0.1 , one with localhost and another with the machine hostname.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points