Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-498

Joran configuration not working in OSGi environment

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 0.9.18
    • 0.9.15
    • logback-classic
    • None
    • OSGi Service Platform Release 4

    Description

      When running in OSGi environment, JoranConfigurator throws a ClassCastException when trying to parse the Logback XML configuration file. The problem seems to be caused by OSGi-unfriendly JAXP parser discovery mechanism as suggested by Dieter Wimberger in his blog post – http://wimpi.coalevo.net/2008/04/hack-how-to-use-logback.html

      "[...] JAXP discovery mechanism assume visibility of the parser through the context ClassLoader of the actual thread, which may cause some troubles."

      Observed exception stack trace:

      Failed to auto configure default logger context
      Reported exception:
      ch.qos.logback.core.joran.spi.JoranException: Parser configuration error occured
      at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:63)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:105)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:76)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:40)
      at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:47)
      at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:108)
      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
      at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:56)
      at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:189)
      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:112)
      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:105)
      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:235)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:208)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
      at com.foo.bar.server.config.Configuration.<clinit>(Configuration.java:244)
      at com.foo.bar.server.ServerBundleActivator.start(ServerBundleActivator.java:39)
      at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:589)
      at org.apache.felix.framework.Felix._startBundle(Felix.java:1671)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
      at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
      at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
      at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
      at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:56)
      ... 21 more

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            pjuhos Pavol Juhos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: