dev@glassfish.java.net

Re: [Bug] NameNotFoundException is occured when use the relative path to lookup

From: Cheng Fang <cheng.fang_at_oracle.com>
Date: Mon, 27 Dec 2010 22:41:38 -0500

Which version of GlassFish? From the stacktrace, it looks like v2.x.
Naming code has changed significantly since v2. Could you also try it
with the latest GlassFish builds?

Please create an issue in glassfish jira
(http://java.net/jira/secure/Dashboard.jspa ) with a complete test app.
I couldn't find the test ejb classes in your previous attachment.

Thanks,
-cheng

On 12/23/10 12:55 AM, Meng XiaoLong wrote:
> GlassFish Dev Team,
>
> Hello everybody.
>
> Sorry for interrupting you.
>
> I am from Fujitsu China. I found a bug when I test JNDI Service's
> lookup method.
>
> #Scene 1 [NameNotFoundException occured]
> ==========================================================
> Specify 'endpoints' property in client application, then use the
> relative path to lookup EJB application. when execute the 2nd lookup
> method, NameNotFoundException is throwed.
>
> client source:
> ----------src start-----------
> System.setProperty("com.sun.appserv.iiop.endpoints", "localhost:3700");
> System.out.println("==========>start: ");
> Context ctx = new InitialContext();
> System.out.println("begin: ");
> WorkerRemote wr = null;
> Context ctx2 = (Context) ctx.lookup("ejb");
> wr = (WorkerRemote) ctx2.lookup("worker01"); //NameNotFoundException
> // wr = (WorkerRemote) ctx.lookup("ejb/worker01");
> System.out.println(wr.work());
> ----------src end-----------
> ===Exception info===
> Exception in thread "main" javax.naming.NameNotFoundException: ejb not
> found
> at
> com.sun.enterprise.naming.TransientContext.resolveContext(TransientContext.java:268)
>
> at
> com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:191)
>
> at
> com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:192)
>
> at
> com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
>
> at
> com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
>
> ==========================================================
>
>
> #Scene 2 [NameNotFoundException is not occurred]
> ==========================================================
> Do not specify 'endpoints' property in client application, use the
> relative path to lookup EJB application. In this scene, can lookup the
> object correctly without NameNotFoundException.
>
> client source:
> ----------src start-----------
> System.out.println("==========>start: ");
> Context ctx = new InitialContext();
> System.out.println("begin: ");
> WorkerRemote wr = null;
> Context ctx2 = (Context) ctx.lookup("ejb");
> wr = (WorkerRemote) ctx2.lookup("worker01");
> // wr = (WorkerRemote) ctx.lookup("ejb/worker01");
> System.out.println(wr.work()); 
> ----------src end-----------
> ==========================================================
>
> About client source and EJB application, Please refer to the attached
> file.
>
> ==howto fix==
> In SerialContext class's lookup method, before
> javax.naming.spi.NamingManager.getObjectInstance(), executing
> resetSticky().
> ---
> if(obj instanceof Context) {
> resetSticky();
> return new SerialContext(name, myEnv);
> }
> resetSticky(); //fix the problem.
> Object retObj =
> javax.naming.spi.NamingManager.getObjectInstance(obj,
> new CompositeName(name),
> null, myEnv);
> return retObj;
> ---
>
> However, I donot know whether this can really fix the problem.
>
> Can Anybody answer me the following 2 questions?
> Question 1: the purpose of stickyContext.
> Question 2: If I changed the processing order whether this can really
> fix the problem?
> ---
> resetSticky(); //fix the problem.
> Object retObj =
> javax.naming.spi.NamingManager.getObjectInstance(obj,
> new CompositeName(name),
> null, myEnv);
> return retObj;
> ---
>
> Best Regard.
>
> Meng XiaoLong
>