users@glassfish.java.net

Can I use mutiple Context for JNDI lookup ?

From: <glassfish_at_javadesktop.org>
Date: Wed, 06 Jun 2007 06:06:50 PDT

Hi, Guru

Version : glassfish-installer-v2-b49
Operatiog System : Solairs9 , Solaris10

I found document about lookup from Forum.
Of course, It OK.

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

Howerver,
Can I use this logic in Client program?
I installed a stand-alone Server using setup.xml file.

As follow, (pseudo code)

    1. Setting Propertis.( port: 3701 : inactive )
    2. InitialContext(props).
    3. Execute lookup.
    
     < Cause Error, because 3701 port is inactive >
     
    4. Setting Propertis.( port: 3702 : on active )
    
    5. InitialContext(props).

    6. Execute lookup.


Run ;
 % java -classpath .:$ASROOT/lib/javaee.jar:$ASROOT/lib/appserv-rt.jar <className>



Snipped source :


        Properties props = new Properties();
    props.setProperty("java.naming.factory.initial"
         , "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("java.naming.factory.url.pkgs"
         , "com.sun.enterprise.naming");
    props.setProperty("java.naming.factory.state"
         , "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
    props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3701");


        InitialContext ctx = new InitialContext(props);
        
        
        Test test = (Test)ctx.lookup("com.app.Test);
        
        
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3702");
        
        
        InitialContext ctx2 = new InitialContext(props);
        
        
        Test test = (Test)ctx2.lookup("com.app.Test);
        

Thank you very much.
[Message sent by forum member 'wildrose' (wildrose)]

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