users@glassfish.java.net

remote JNDI lookup (datasource)

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 Jan 2008 04:34:45 PST

Hi

I'm trying to do a remote jndi lookup to a glassfish instance from within the IDE (Intellij), in this case just a lookup of a datasource. I'm using this code: (added a list of jndi names just for verification)

  Properties props = new Properties();

        props.setProperty("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
        props.setProperty("java.naming.provider.url", "iiop://....:...");
        props.setProperty("java.naming.security.principal", "..");
        props.setProperty("java.naming.security.credentials", "..");

        try {
            InitialContext ctx = new InitialContext(props);

            NamingEnumeration list = ctx.list("");
            while (list.hasMore()) {
                NameClassPair ncPair = (NameClassPair) list.next();

                System.out.print(ncPair.getName() + " (type ");
                System.out.println(ncPair.getClassName() + ")");
            }
            Object o = ctx.lookup("jdbc/testDS");
        }
        catch (NamingException e) {
            e.printStackTrace();
        }

The lookup of the context works just fine. The list (while(list..) prints:

SerialContextProvider (type com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)
ejb (type com.sun.jndi.cosnaming.CNCtx)
INITIAL_GIS (type com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)

And the lookup fails with:

javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
        at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:453)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:492)
....

Afaik, the listing should print the contents of the JNDI tree and it doesn't seem to do that. At least not the JNDI names i'm expecting.

And the lookup fails but i've viewed the JNDI tree in the admin gui and the names i've been trying to lookup are all there.

Any ideas ?

Might add that i've included appsrv-rt.jar, ext, ws, j2ee and so forth and nothing seems to make a difference.

/Laban
[Message sent by forum member 'laban' (laban)]

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