Nice idea :-) We can even reuse the slf4j logger by using an optional package import and check if it is present in the activator, else default to the stderr based one from jetty. The other solution would be to use the OSGi service directly. I will investigate this issue further and come with a fix in pax-web.
On Dec 4, 2007 4:51 AM, Niclas Hedhman <[EMAIL PROTECTED]> wrote: > On Monday 03 December 2007 21:21, Guillaume Nodet wrote: > > > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) > > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > > at org.mortbay.log.Slf4jLog.<init>(Slf4jLog.java:51) > > at org.mortbay.log.Slf4jLog.getLogger(Slf4jLog.java:138) > > > > This happens when starting pax-web when pax-logging is already > installed. > > > I'm not sure if the problem is in jetty (I suppose the "at > > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)" line > means > > that it does not really use the correct classloader, or if pax-web > should > > fix that somehow. > > Has anyone already seen this exception ? > > > No, but looking at the code at jetty.mortbay.org, I am not surprised. > > Jetty for some awkward reason is doing its own classloading management of > the > org.slf4j.Logger class. I can't think of any sane reason to do that, > but... > > The problematic line is; > > slf4j = Thread.currentThread().getContextClassLoader()==null > ? Class.forName(LOGGER) > : Thread.currentThread().getContextClassLoader().loadClass(LOGGER); > > And the stack trace is showing that the ContextClassLoader is being used. > I > also didn't know that Class.forName() would work at all in OSGi setting. > > Anyway, I think Pax Web should actually prevent this actively. > > By calling > org.mortbay.log.Log.setLog( org.mortbay.log.Logger log ) > we can prevent the entire classloading tricks that Jetty does. > > The Logger interface isn't much; > > > package org.mortbay.log; > > /** Logging Facade > * A simple logging facade that is intended simply to capture the style > * of logging as used by Jetty. > * > */ > public interface Logger > { > public boolean isDebugEnabled(); > > /** Mutator used to turn debug on programatically. > * Implementations operation in which case an appropriate > * warning message shall be generated. > */ > public void setDebugEnabled(boolean enabled); > > public void info(String msg,Object arg0, Object arg1); > public void debug(String msg,Throwable th); > public void debug(String msg,Object arg0, Object arg1); > public void warn(String msg,Object arg0, Object arg1); > public void warn(String msg, Throwable th); > public Logger getLogger(String name); > } > > > Cheers > -- > Niclas Hedhman, Software Developer > > I live here; http://tinyurl.com/2qq9er > I work here; http://tinyurl.com/2ymelc > I relax here; http://tinyurl.com/2cgsug > > _______________________________________________ > general mailing list > general@lists.ops4j.org > http://lists.ops4j.org/mailman/listinfo/general > -- Cheers, Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/
_______________________________________________ general mailing list general@lists.ops4j.org http://lists.ops4j.org/mailman/listinfo/general