You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@excalibur.apache.org by Neeme Praks <ne...@apache.org> on 2004/07/14 01:25:24 UTC
Re: svn commit: rev 22089 - excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools
Hmm, as far as I can see (also written in
FortressBean.initializeCommonsLogging() javadocs), latest
commons-logging release (1.0.4) contains AvalonLogger
(http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/AvalonLogger.html).
also http://jakarta.apache.org/commons/logging/RELEASE-NOTES.txt
contains a reference:
[AvalonLogger] Added AvalonLogger, which wraps the logger used by the
Avalon framework. As with other implementations, this
is compiled only if the appropriate dependencies are
satisfied.
and
http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.jar
seems to contain it...
Should I revert the change? Or have I misunderstood the issue? :-)
bloritsch@apache.org wrote:
>Author: bloritsch
>Date: Thu Jun 24 14:28:42 2004
>New Revision: 22089
>
>Added:
> excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java
>Modified:
> excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java
>Log:
>add AvalonLogger because none of the commons logging jars contains it
>
>Added: excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java
>==============================================================================
>--- (empty file)
>+++ excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java Thu Jun 24 14:28:42 2004
>@@ -0,0 +1,115 @@
>+package org.apache.avalon.fortress.tools;
>+
>+import org.apache.avalon.framework.logger.Logger;
>+import org.apache.commons.logging.Log;
>+
>+/**
>+ * Created by IntelliJ IDEA. User: bloritsch Date: Jun 24, 2004 Time:
>+ * 5:07:47 PM To change this template use File | Settings | File
>+ * Templates.
>+ */
>+public class AvalonLogger implements Log
>+{
>+ private static Logger m_default;
>+ private Logger m_log;
>+
>+ public static void setDefaultLogger(Logger logger)
>+ {
>+ m_default = logger;
>+ }
>+
>+ public AvalonLogger(String category)
>+ {
>+ m_log = m_default.getChildLogger( category );
>+ }
>+
>+ public boolean isDebugEnabled()
>+ {
>+ return m_log.isDebugEnabled();
>+ }
>+
>+ public boolean isErrorEnabled()
>+ {
>+ return m_log.isErrorEnabled();
>+ }
>+
>+ public boolean isFatalEnabled()
>+ {
>+ return m_log.isFatalErrorEnabled();
>+ }
>+
>+ public boolean isInfoEnabled()
>+ {
>+ return m_log.isInfoEnabled();
>+ }
>+
>+ public boolean isTraceEnabled()
>+ {
>+ return m_log.isDebugEnabled();
>+ }
>+
>+ public boolean isWarnEnabled()
>+ {
>+ return m_log.isWarnEnabled();
>+ }
>+
>+ public void trace( Object o )
>+ {
>+ m_log.debug( o.toString() );
>+ }
>+
>+ public void trace( Object o, Throwable throwable )
>+ {
>+ m_log.debug( o.toString(), throwable );
>+ }
>+
>+ public void debug( Object o )
>+ {
>+ m_log.debug( o.toString() );
>+ }
>+
>+ public void debug( Object o, Throwable throwable )
>+ {
>+ m_log.debug( o.toString(), throwable);
>+ }
>+
>+ public void info( Object o )
>+ {
>+ m_log.info( o.toString() );
>+ }
>+
>+ public void info( Object o, Throwable throwable )
>+ {
>+ m_log.info( o.toString(), throwable );
>+ }
>+
>+ public void warn( Object o )
>+ {
>+ m_log.warn( o.toString() );
>+ }
>+
>+ public void warn( Object o, Throwable throwable )
>+ {
>+ m_log.warn( o.toString(), throwable );
>+ }
>+
>+ public void error( Object o )
>+ {
>+ m_log.error( o.toString() );
>+ }
>+
>+ public void error( Object o, Throwable throwable )
>+ {
>+ m_log.error( o.toString(), throwable );
>+ }
>+
>+ public void fatal( Object o )
>+ {
>+ m_log.fatalError( o.toString() );
>+ }
>+
>+ public void fatal( Object o, Throwable throwable )
>+ {
>+ m_log.fatalError( o.toString(), throwable );
>+ }
>+}
>
>Modified: excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java
>==============================================================================
>--- excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java (original)
>+++ excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java Thu Jun 24 14:28:42 2004
>@@ -1,16 +1,16 @@
>-/*
>+/*
> * Copyright 2003-2004 The Apache Software Foundation
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
>- * You may obtain a copy of the License at
>- *
>+ * You may obtain a copy of the License at
>+ *
> * http://www.apache.org/licenses/LICENSE-2.0
>- *
>+ *
> * Unless required by applicable law or agreed to in writing, software
> * distributed under the License is distributed on an "AS IS" BASIS,
> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> * implied.
>- *
>+ *
> * See the License for the specific language governing permissions and
> * limitations under the License.
> */
>@@ -42,7 +42,6 @@
> public class FortressBean implements Initializable, LogEnabled, Serviceable, Disposable {
>
> private static final String COMMONS_LOG_PROPERTY = "org.apache.commons.logging.Log";
>- private static final String COMMONS_AVALON_LOGGER = "org.apache.commons.logging.impl.AvalonLogger";
>
> private final FortressConfig config = new FortressConfig();
> private Logger logger = null;
>@@ -89,7 +88,7 @@
> // Get the root container initialized
> this.cm = new DefaultContainerManager(config.getContext());
> ContainerUtil.initialize(cm);
>- initializeCommonsLogging(cl);
>+ initializeCommonsLogging();
> this.container = (DefaultContainer) cm.getContainer();
> this.sm = container.getServiceManager();
> }
>@@ -99,22 +98,12 @@
> * Use reflection to set up commons logging. If commons logging is available, it will be set up;
> * if it is not available, this section is ignored. This needs version 1.0.4 (or later) of commons
> * logging, earlier versions do not have avalon support.
>- *
>- * @param cl class loader to look for commons logging classes
> */
>- private void initializeCommonsLogging(ClassLoader cl) {
>+ private void initializeCommonsLogging() {
> try {
>- //if commons logging is available, set the static logger for commons logging
>- Class commonsLoggerClass;
>- if (cl != null) {
>- commonsLoggerClass = cl.loadClass(COMMONS_AVALON_LOGGER);
>- } else {
>- commonsLoggerClass = Class.forName(COMMONS_AVALON_LOGGER);
>- }
>- Method setDefaultLoggerMethod = commonsLoggerClass.getMethod("setDefaultLogger", new Class[] {Logger.class});
>- setDefaultLoggerMethod.invoke(null, new Object[] {cm.getLogger()});
>- //set the system property to use avalon logger
>- System.setProperty(COMMONS_LOG_PROPERTY, COMMONS_AVALON_LOGGER);
>+ AvalonLogger.setDefaultLogger( cm.getLogger() );
>+
>+ System.setProperty(COMMONS_LOG_PROPERTY, AvalonLogger.class.getName());
> } catch (Exception e) {
> if (getLogger().isDebugEnabled()) getLogger().debug("error while initializing commons logging: " + e.getClass().getName() + ", " + e.getMessage());
> }
>@@ -127,7 +116,7 @@
> public static final String PROPERTY_CONTAINER_CLASS = "container.class";
> public static final String PROPERTY_CONTAINER_CONFIGURATION = "container.configuration";
> public static final String PROPERTY_CONTEXT_DIRECTORY = "context.directory";
>- public static final String PROPERTY_INSTRUMENT_MANAGER_CONFIGURATION =
>+ public static final String PROPERTY_INSTRUMENT_MANAGER_CONFIGURATION =
> "instrument.manager.configuration";
> public static final String PROPERTY_INVOKE_METHOD = "invoke.method";
> public static final String PROPERTY_LOGGER_MANAGER_CONFIGURATION = "logger.manager.configuration";
>@@ -213,9 +202,9 @@
> }
>
> /**
>- * The container implementation has to be a subclass of
>+ * The container implementation has to be a subclass of
> * <code>org.apache.avalon.fortress.impl.DefaultContainer</code>.
>- *
>+ *
> * @param containerClass fully qualified class name of the container implementation class.
> */
> public void setContainerClass(String containerClass) throws Exception {
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
>For additional commands, e-mail: scm-help@excalibur.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: svn commit: rev 22089 - excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools
Posted by Neeme Praks <ne...@apache.org>.
Berin Loritsch wrote:
> It would if clazz is null. I believe that is the problem I ran into.
but if the clazz is null, then it should give NPE already on the line
"clazz.getName()", not later...
Neeme
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: svn commit: rev 22089 - excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools
Posted by Berin Loritsch <bl...@d-haven.org>.
Neeme Praks wrote:
> ok, I reverted the change now.
>
> however, I had to comment out commons-logging dependency in order for
> the tests to pass. if commons-logging is present in the classpath, the
> logs are redirected to avalon, otherwise commons-logging initialization
> is ignored.
>
> if commons-logging is in the classpath and is initialized, I get a very
> mysterious NPE (see the attached test report)
>
> it seems that there is a null child log category name passed to
> org.apache.log.Logger.getChildLogger() method. But this should not
> really happen, as the initial call to get that child logger comes from
> BeanUtils
> (org.apache.commons.beanutils.MethodUtils.<clinit>(MethodUtils.java:103)):
> private static Log log = LogFactory.getLog(MethodUtils.class);
>
> LogFactoryImpl converts that class argument into a String by using
> "clazz.getName()" and this should never return null...
>
> So it remains mystery for me, how can there be a NPE...
>
It would if clazz is null. I believe that is the problem I ran into.
--
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe trying to
produce bigger and better idiots. So far, the Universe is winning."
- Rich Cook
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/
Re: svn commit: rev 22089 - excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools
Posted by Neeme Praks <ne...@apache.org>.
ok, I reverted the change now.
however, I had to comment out commons-logging dependency in order for
the tests to pass. if commons-logging is present in the classpath, the
logs are redirected to avalon, otherwise commons-logging initialization
is ignored.
if commons-logging is in the classpath and is initialized, I get a very
mysterious NPE (see the attached test report)
it seems that there is a null child log category name passed to
org.apache.log.Logger.getChildLogger() method. But this should not
really happen, as the initial call to get that child logger comes from
BeanUtils
(org.apache.commons.beanutils.MethodUtils.<clinit>(MethodUtils.java:103)):
private static Log log = LogFactory.getLog(MethodUtils.class);
LogFactoryImpl converts that class argument into a String by using
"clazz.getName()" and this should never return null...
So it remains mystery for me, how can there be a NPE...
Could someone else uncomment commons-logging in
fortress/bean/project.xml and try to build the jar. Does the test fail
the same way?
Neeme
Berin Loritsch wrote:
> Neeme Praks wrote:
>
>> Hmm, as far as I can see (also written in
>> FortressBean.initializeCommonsLogging() javadocs), latest
>> commons-logging release (1.0.4) contains AvalonLogger
>> (http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/AvalonLogger.html).
>>
>>
>> also http://jakarta.apache.org/commons/logging/RELEASE-NOTES.txt
>> contains a reference:
>>
>> [AvalonLogger] Added AvalonLogger, which wraps the logger used by
>> the
>> Avalon framework. As with other implementations, this
>> is compiled only if the appropriate dependencies are
>> satisfied.
>>
>>
>> and
>> http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.jar
>>
>> seems to contain it...
>>
>> Should I revert the change? Or have I misunderstood the issue? :-)
>
>
> It wasn't in anything I found to download. :(
>
Re: svn commit: rev 22089 - excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools
Posted by Berin Loritsch <bl...@d-haven.org>.
Neeme Praks wrote:
> Hmm, as far as I can see (also written in
> FortressBean.initializeCommonsLogging() javadocs), latest
> commons-logging release (1.0.4) contains AvalonLogger
> (http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/AvalonLogger.html).
>
>
> also http://jakarta.apache.org/commons/logging/RELEASE-NOTES.txt
> contains a reference:
>
> [AvalonLogger] Added AvalonLogger, which wraps the logger used by the
> Avalon framework. As with other implementations, this
> is compiled only if the appropriate dependencies are
> satisfied.
>
>
> and
> http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.jar
> seems to contain it...
>
> Should I revert the change? Or have I misunderstood the issue? :-)
It wasn't in anything I found to download. :(
--
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe trying to
produce bigger and better idiots. So far, the Universe is winning."
- Rich Cook
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/