dev@glassfish.java.net

Major problem with JNDI at webapp start

From: Lilianne E. Blaze <lilianne_blaze_at_tlen.pl>
Date: Sat, 13 Oct 2007 21:46:10 +0200

Hello,
I'm using Glassfish b58g, the one provided with Netbeans 6.0b1. It seems
JNDI is unavailable at webapp start.

I have:
    <env-entry>
        <env-entry-name>xxx/test</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>test 2</env-entry-value>
    </env-entry>
In web.xml

And:
  <Environment name="xxx/test" type="java.lang.String" value="test4"/>
In /META-INF/context.xml

Now I'm not sure if Glassfish uses /META-INF/context.xml, I think it
does, but <env-entry> is standard JEE functionality.

I'm using the following code:
      Context initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");
      String value = (String)envCtx.lookup("xxx/test");

To get the value at webapp start. Obviously, it should get "test 2". I
throws "javax.naming.NameNotFoundException: No object bound" instead.
The same code works flawlessly on Tomcat 6.0.13.

Changing "xxx/test" to just "test" in all places makes no difference.

Due to technical requirements I can't use lazy-init here and I do have
to use JNDI. So basically this is a showstopper for me.

Greetings, Lilianne E. Blaze