users@glassfish.java.net

Re: InitialContext question

From: <glassfish_at_javadesktop.org>
Date: Tue, 10 Jul 2007 01:42:34 PDT

Thanks in advance Mahesh...

That is exactly what I thought I'd to do. But....executing my code, which is like yours....

        Properties props1;
        Properties props2;

        props1 = new Properties();
        props1.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
        props1.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.168.2");
        props1.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        
        try
        {
            context1 = new InitialContext(props1);
            HelloService_Remote remote = (HelloService_Remote) context1.lookup("ejb/HelloService_Bean");
            System.out.println("BINGO 1 --> " + remote);
        }
        catch (CommunicationException ex)
        { ex.printStackTrace(); }
        catch (NamingException ex)
        { ex.printStackTrace(); }

        
        props2 = new Properties();
        props2.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
        props2.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
        props2.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        
        try
        {
            context2 = new InitialContext(props2);
            HelloService_Remote remote = (HelloService_Remote) context2.lookup("ejb/HelloService_Bean");
            System.out.println("BINGO 2 --> " + remote);
        }
        catch (CommunicationException ex)
        { ex.printStackTrace(); }
        catch (NamingException ex)
        { ex.printStackTrace(); }


I get the following output


run-single:
BINGO 1 --> cat.htmc.server.beans.services._HelloService_Remote_Wrapper_at_d9f1ac94
BINGO 2 --> cat.htmc.server.beans.services._HelloService_Remote_Wrapper_at_d9f1ac94
BUILD SUCCESSFUL (total time: 6 seconds)


As you can see both calls return the same instance. This should'nt be correct because in the second one of those server there is not HelloService (it is not installed) so it should return a Not Found Exception.

I've been looking around my code for any bug but I can't find one. I don't know what else to do. Any idea????

--Xavier
[Message sent by forum member 'xavier_ferret' (xavier_ferret)]

http://forums.java.net/jive/thread.jspa?messageID=225901