[logback-user] question reg. reading JNDI env entries

Ceki Gülcü ceki at qos.ch
Mon Jun 6 23:14:57 CEST 2011

Hello Ravi,

This is quite strange because for some name 'n', the JNDI lookup code in 
logback essentially does InitialContext().lookup(n) the same code that 
seems to work for you. Could the discrepency be attributed to 
differences in the class loader for logback and the servlet code which 
is able to correctly read the JNDI entries? Where are the logback 
classes located on your application's class path?


On 06/06/2011 10:25 PM, Ravikanth Gangarapu wrote:
> Hi,
> I am using logback-classic (0.9.28) for a web application running on
> tomcat 5.5.
> I am trying to read the JNDI env entry values using the <insertFromJNDI
> env-entry-name="java:comp/env/stderr-logging" as="stdErrLogging" /> tag
> in the logback.xml file.
> I have lots of env entry values that can be read from
> META-INF/context.xml file. For this specific example, my context.xml
> file has this.
> <context>
> ….
> <Environment name="stderr-logging" type="java.lang.String" value="true"/>
> ….
> But, this insertFromJNDI tags always says the entry value is null or
> empty. However, Once I am in a servlet code, new
> InitialContext().lookup(“java:comp/env/stderr-logging") retrieves the
> correct value from context xml file.
> I looked in the JNDIUtil class from ch.qos.logback.classic.util package
> and the code throws error saying “javax.naming.NameNotFoundException:
> Name java:comp is not bound in this Context”.
> Would somebody know how to read the environment entry values from the
> META-INF/context.xml file ?
> Thanks for help
> Ravi

More information about the Logback-user mailing list