Yikes, I take some of this back. Looks like support for reading
context.xml was added to Glassfishearlier this year (see
http://weblogs.java.net/blog/amyroh/archive/2007/05/context_webapp_1.html)
Maybe there is a bug... I will check.
-Peter
Peter Williams wrote:
> sun-web.xml is the server specific descriptor for webapps in
> Glassfish. Glassfish does not use context.xml in any way.
>
> However, sun-web.xml does not provides fields to override env-entry
> elements from web.xml. I believe the expectation is that you would
> simply modify web.xml directly if the values needed changing.
>
> That said, I tried your example just now using my personal development
> build of NB6 (roughly equivalent to the current nightly build of same)
> and it worked flawlessly, no exceptions. The value was read from
> web.xml exactly as expected.
>
> You don't mention where your context code is. Mine was in the
> processRequest() method of generic NetBeans generated servlet.
>
> -Peter
>
> Lilianne E. Blaze wrote:
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>