Uploaded image for project: 'JBoss Logging'
  1. JBoss Logging
  2. JBLOGGING-111

LoggerProvider configured with new ServiceLoader crash

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.2.0.Final
    • 3.2.0.Beta1
    • None
    • None
      • Add a serviceLoader file in the META-INF of a jar using a different LoggerProvider than the default.
      • Load an application using the JBoss logging (ex. Hibernate based application)

      There is a new feature in the beta which uses the ServiceLoader to specify a LoggerProvider to be used by JBoss Logging.

      org.jboss.logging.LoggerProviders snippet :

      // Next try for a service provider
              try {
                  final ServiceLoader<LoggerProvider> loader = ServiceLoader.load(LoggerProvider.class, cl);
                  if (loader.iterator().hasNext()) {
                      return loader.iterator().next();
                  }
              } catch (Throwable ignore) {
                  // TODO consider printing the stack trace as it should only happen once
              }
      

      When you try to configure a provider (ex. org.jboss.logging.Slf4jLoggerProvider), the ServiceLoader crash silently and ignore the provider.

      java.util.ServiceConfigurationError: org.jboss.logging.LoggerProvider: Provider org.jboss.logging.Slf4jLoggerProvider could not be instantiated: java.lang.IllegalAccessException: Class java.util.ServiceLoader$LazyIterator can not access a member of class org.jboss.logging.Slf4jLoggerProvider with modifiers ""
      	at java.util.ServiceLoader.fail(ServiceLoader.java:207)
      	at java.util.ServiceLoader.access$100(ServiceLoader.java:164)
      	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353)
      	at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
      	at org.jboss.logging.LoggerProviders.findProvider(LoggerProviders.java:70)
      	at org.jboss.logging.LoggerProviders.find(LoggerProviders.java:32)
      	at org.jboss.logging.LoggerProviders.<clinit>(LoggerProviders.java:29)
      	at org.jboss.logging.Logger.getLogger(Logger.java:2177)
      	at org.jboss.logging.Logger$1.run(Logger.java:2277)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at org.jboss.logging.Logger.getMessageLogger(Logger.java:2241)
      	at org.jboss.logging.Logger.getMessageLogger(Logger.java:2228)
      	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:176)
              ...
      

      This is caused by the fact that all JBoss providers are not public classes and are instead package classes.

              jperkins-rhn James Perkins
              psychobaatezu Frederic Allard (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: