[logback-user] Problem with Groovy detection in Glassfish 3.1.2.2

ceki ceki at qos.ch
Mon Apr 8 10:33:58 CEST 2013


Hi Carl,

Thank you for your detailed message.

It's a bug in the EnvUtil class which wrongly assumes that the 
classloader for the EnvUtil class cannot be null. However, per the 
javadocs of the Class.getClassLoader method:

   Some implementations may use null to represent the bootstrap class
   loader. This method will return null in such implementations if this
   class was loaded by the bootstrap class loader.

Could you please file a jira issue report for this bug? A github pull 
request would also be appreciated, although not strictly necessary.

On 08.04.2013 08:50, Karl Spies wrote:
> Hi,
>
> my goal is to use slf4j and logback in our Glassfish servers. But I
> came a cross with an error in the groovy detection. Please see the
> stacktrace below.
>
> I think the problem has something to do with the classloader in
> glassfish. The libraries are placed in the root lib/endorsed folder. I
> need them there to have the highest priority while classloading.
>
> Is this a problem with my setup and idea, or do I encountered a real
> misbehavior.
>
> I attached a patch within this mail.
>
> Thanks in advance.
>
> Best Regards
>
> Karl
>
> Stacktrace and Log:
>
> Apr 05, 2013 11:47:05 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
> INFO: JVM invocation command line:
> -XX:+UnlockDiagnosticVMOptions
> -XX:MaxPermSize=256m
> -XX:PermSize=64m
> -XX:NewRatio=2
> -Xmx512m
> -client
> -javaagent:C:/glassfish3/glassfish/lib/monitor/flashlight-agent.jar
> -Dfelix.fileinstall.disableConfigSave=false
> -Djavax.net.ssl.keyStore=C:\glassfish3\glassfish\domains\domain1/config/keystore.jks
> -Djava.awt.headless=true
> -Dfelix.fileinstall.poll=5000
> -Djava.endorsed.dirs=C:\glassfish3\glassfish/modules/endorsed;C:\glassfish3\glassfish/lib/endorsed
> -Dfelix.fileinstall.bundles.startTransient=true
> -Djavax.net.ssl.trustStore=C:\glassfish3\glassfish\domains\domain1/config/cacerts.jks
> -Djava.util.logging.config.file=C:\glassfish3\glassfish\domains\domain1/config/my_logging.properties
> -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
> -Djava.security.auth.login.config=C:\glassfish3\glassfish\domains\domain1/config/login.conf
> -DANTLR_USE_DIRECT_CLASS_LOADING=true
> -Dgosh.args=--nointeractive
> -Dosgi.shell.telnet.maxconn=1
> -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
> -Dfelix.fileinstall.dir=C:\glassfish3\glassfish/modules/autostart/
> -Dosgi.shell.telnet.port=6666
> -Djava.security.policy=C:\glassfish3\glassfish\domains\domain1/config/server.policy
> -Dfelix.fileinstall.log.level=2
> -Dcom.sun.aas.instanceRoot=C:\glassfish3\glassfish\domains\domain1
> -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
> -Dosgi.shell.telnet.ip=127.0.0.1
> -Dcom.sun.aas.installRoot=C:\glassfish3\glassfish
> -Djava.ext.dirs=c:\Program Files\Java\jdk1.7.0_15/lib/ext;c:\Program
> Files\Java\jdk1.7.0_15/jre/lib/ext;C:\glassfish3\glassfish\domains\domain1/lib/ext
> -Dfelix.fileinstall.bundles.new.start=true
> -Dlogback.configurationFile=C:\glassfish3\glassfish\domains\domain1/config/logback.xml
> Apr 05, 2013 11:47:05 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
> INFO: Successfully launched in 9 msec.
> Launching GlassFish on Felix platform
> 11:47:05,393 |-INFO in ch.qos.logback.classic.LoggerContext[default] -
> Found resource [C:\glassfish3\glassfish\domains\domain1/config/logback.xml]
> at [file:/C:/glassfish3/glassfish/domains/domain1/config/logback.xml]
> 11:47:05,455 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter at 1:29
> - RuntimeException in Action for tag [configuration]
> java.lang.NullPointerException
> at java.lang.NullPointerException
> at at ch.qos.logback.classic.util.EnvUtil.isGroovyAvailable(EnvUtil.java:25)
> at at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:59)
> at at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
> at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
> at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
> at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
> at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157)
> at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
> at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
> at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
> at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
> at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
> at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
> at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
> at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
> at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
> at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
> at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
> at at org.slf4j.bridge.SLF4JBridgeHandler.getSLF4JLogger(SLF4JBridgeHandler.java:204)
> at at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:291)
> at at java.util.logging.Logger.log(Logger.java:565)
> at at java.util.logging.Logger.doLog(Logger.java:586)
> at at java.util.logging.Logger.logp(Logger.java:755)
> at at org.glassfish.embeddable.GlassFishRuntime.getRuntimeBuilder(GlassFishRuntime.java:181)
> at at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime.java:156)
> at at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.java:110)
> at at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:112)
> at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at at java.lang.reflect.Method.invoke(Method.java:601)
> at at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
> at at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
> 11:47:05,457 |-INFO in
> ch.qos.logback.classic.joran.JoranConfigurator at 399f9f8e - Registering
> current configuration as safe fallback point
> 11:47:05,459 |-WARN in Logger[org.glassfish.embeddable] - No appenders
> present in context [default] for logger [org.glassfish.embeddable].
>
> Patched class:
>
> /**
>   * Logback: the reliable, generic, fast and flexible logging framework.
>   * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
>   *
>   * This program and the accompanying materials are dual-licensed under
>   * either the terms of the Eclipse Public License v1.0 as published by
>   * the Eclipse Foundation
>   *
>   *   or (per the licensee's choosing)
>   *
>   * under the terms of the GNU Lesser General Public License version 2.1
>   * as published by the Free Software Foundation.
>   */
> package ch.qos.logback.classic.util;
>
> /**
>   * @author Ceki Gücü
>   */
> public class EnvUtil {
>
>
>    static public boolean isGroovyAvailable() {
>      ClassLoader classLoader =  EnvUtil.class.getClassLoader();
> if(classLoader == null) {
> return false;
> }
>      try {
>        Class bindingClass = classLoader.loadClass("groovy.lang.Binding");
>        return (bindingClass != null);
>      } catch (ClassNotFoundException e) {
>        return false;
>      }
>    }
>
> }
>
>
> --
>
> Karl Spies, Java Entwickler
>
> Tel.: +49  5207 9299-345
> mailto: Karl.Spies at synaxon.de
> Jabber: Karl.Spies at jabber.synaxon.de
>
> SYNAXON AG
> Falkenstraße 31
> 33758 Schloß Holte-Stukenbrock
>
> Vorstand: Frank Roebers (Vorsitzender), Andreas Wenninger, Mark Schröder
> Aufsichtsratsvorsitzender: Dr. Günter Lewald
> Handelsregister Bielefeld HRB 36014
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>


-- 
Ceki
65% of statistics are made up on the spot


More information about the Logback-user mailing list