Hi Ceki,
        I have logback-core, classic, janino, commons-compiler jar files 
located under WEB-INF/lib folder, and the logback.xml is under WEB-INF/classes. 
In the console, the logback logs appear ahead of the application specific 
servlet and filter (from web.xml) init method System out statements.

I have modified the InsertFromJNDIAction class to print its classloader and did 
the same for servlet and filter init methods too. All of them printed the same 
class loader name.

So, I added, 

ClassLoader loader = Thread.currentThread().getContextClassLoader();
System.out.println("InsertFromJNDIAction "+loader.getClass().getName()+" 
"+loader.hashCode()+" "+loader.toString());

org.apache.catalina.loader.WebappClassLoader 1024180126 WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@46c837cd

The jndi context lookup is successful in servlet and filter init methods to 
print the env-entry-value. Logback still threw the error for lookup.

Thanks for your help
Ravi

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Ceki Gülcü
Sent: Monday, June 06, 2011 5:15 PM
To: logback users list
Subject: Re: [logback-user] question reg. reading JNDI env entries

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?

--
Ceki

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

_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user
_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user

Reply via email to