[logback-dev] [JIRA] Commented: (LBCLASSIC-211) Logback fails to configure in OSGI container, when multiple configurations found

Holger Hoffstätte (JIRA) noreply-jira at qos.ch
Sun Aug 15 20:51:18 CEST 2010


    [ http://jira.qos.ch/browse/LBCLASSIC-211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11819#action_11819 ] 

Holger Hoffstätte commented on LBCLASSIC-211:
---------------------------------------------

It seems to me that contrary to the subject the problem here is not due to multiple configurations, but a combination of a) logback's OSGi unawareness and b) the existence of multiple bindings (backends) on the classpath. One of your bundles seems to embed slf4j, and things go downhill from there.
We're using slf4j + logback in both equinox and felix and have not seen this error.


> Logback fails to configure in OSGI container, when multiple configurations found
> --------------------------------------------------------------------------------
>
>                 Key: LBCLASSIC-211
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-211
>             Project: logback-classic
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 0.9.20
>         Environment: Apache felix OSGI container, profiling with JProbe.
> Sun JDK 1.6.0_17
>            Reporter: David Riseley
>            Assignee: Logback dev list
>            Priority: Minor
>
> When we attempt to profile our application, which runs in an Apache Felix OSGI container,  using JProbe the Logback configuration fails with the following exception:
> Failed to instantiate [ch.qos.logback.classic.LoggerContext]
> Reported exception:
> java.lang.IllegalArgumentException: name
>         at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:458)
>         at sun.misc.URLClassPath$1.next(URLClassPath.java:195)
>         at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:205)
>         at java.net.URLClassLoader$3$1.run(URLClassLoader.java:393)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader$3.next(URLClassLoader.java:390)
>         at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:415)
>         at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
>         at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
>         at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
>         at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
>         at ch.qos.logback.core.util.Loader.getResourceOccurenceCount(Loader.java:58)
>         at ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning(ContextInitializer.java:131)
>         at ch.qos.logback.classic.util.ContextInitializer.statusOnResourceSearch(ContextInitializer.java:154)
>         at ch.qos.logback.classic.util.ContextInitializer.findConfigFileURLFromSystemProperties(ContextInitializer.java:88)
>         at ch.qos.logback.classic.util.ContextInitializer.findURLOfDefaultConfigurationFile(ContextInitializer.java:97)
>         at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:119)
>         at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:83)
>         at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54)
>         at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
>         at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
>         at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
>         at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
>         at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
>         at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261)
>         at com.example.csp.gui.interfaces.logger.ABCDGUILoggerImpl.getLogger(ABCDGUILoggerImpl.java:74)
>         at com.example.csp.gui.interfaces.logger.ABCDGUILoggerFactory.getLogger(ABCDGUILoggerFactory.java:51)
>         at com.example.csp.gui.kernel.util.ABCDGUIKernelUtil.<clinit>(ABCDGUIKernelUtil.java:61)
>         at com.example.csp.gui.kernel.context.impl.ABCDGUIKernelContextImpl.setAppBaseBundleInContext(ABCDGUIKernelContextImpl.java:207)
>         at com.example.csp.gui.kernel.context.impl.ABCDGUIKernelContextImpl.init(ABCDGUIKernelContextImpl.java:93)
>         at com.example.csp.gui.kernel.context.impl.ABCDGUIKernelContextImpl.<init>(ABCDGUIKernelContextImpl.java:58)
>         at com.example.csp.gui.kernel.activator.impl.KernelActivatorImpl.start(KernelActivatorImpl.java:101)
>         at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:589)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in [jar:file:/C:/ngawab/wab_code/code/source/wnb-common-bundles/wnb-common-client/startup-2.0.3/csp-gui-thickclient-bootstrap-2.0.3-all.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in [bundle://4.0:1/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
> After which we get no logging at all.
> I appreciate that this will be difficult to reproduce , and I think may be related to the "bundle://" URL format not being recognised, so I had a look at the code in 
> ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning()
> Currently it catches an IOExeception when calling Loader.getResourceOccurenceCount(), however from the stack trace this can also throw an. IllegalArgumentException
> So could :
> try {
>       urlList = Loader.getResourceOccurenceCount(resourceName, classLoader);
>     } catch (IOException e) {
>       sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
>           loggerContext, e));
>     }
> Become:
> try {
>       urlList = Loader.getResourceOccurenceCount(resourceName, classLoader);
>     } catch (Exception e) {
>       sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
>           loggerContext, e));
>     }
> I did try this in our environment , and the logging did get successfully configured after this change ( although it wasn't pretty.... :-> )

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


More information about the logback-dev mailing list