Maybe the question is: - Should there be a key at all on Android? - If there is a key, then it may be null
Gary On Wed, Jul 16, 2014 at 1:03 PM, Remko Popma <[email protected]> wrote: > Where do we document that we put the hostName in the context properties? > That is probably the place to mention that for Android the value will be > "unknown". > > The JMX stuff will not work because Android doesn't support it. This is > expected, so there is not much to explain here. > > > On Wed, Jul 16, 2014 at 11:26 PM, Gary Gregory <[email protected]> > wrote: > >> We need an Android section on the site explain what we know will not work >> and what we disable... >> >> Gary >> >> >> On Wed, Jul 16, 2014 at 10:25 AM, Matt Sicker <[email protected]> wrote: >> >>> I think it's rather technical why we get one exception or the other. The >>> VerifyError would happen during linkage, while the no class def would >>> happen during loading. The VerifyError was in a constructor. The other one >>> might be in a different location. You'd probably get an >>> ExceptionInInitializationError if it happened inside the static block for >>> instance. >>> >>> >>> On 16 July 2014 09:18, Remko Popma <[email protected]> wrote: >>> >>>> Hm... Good point. I will remove the Environment class and put a >>>> try/catch Throwable around the >>>> Server.reregisterMBeansAfterReconfigure invocation. >>>> >>>> >>>> On Wed, Jul 16, 2014 at 11:02 PM, Gary Gregory <[email protected]> >>>> wrote: >>>> >>>>> Yeah, big mystery. I'm not sure we should have code like "if ! >>>>> isAndroid()..." It might be better to // comment and catch >>>>> errors/exceptions because who know how Android will change. >>>>> >>>>> Gary >>>>> >>>>> >>>>> On Wed, Jul 16, 2014 at 9:58 AM, Remko Popma <[email protected]> >>>>> wrote: >>>>> >>>>>> But beats me why the JNDI stuff would throw a VerifyError and the JMX >>>>>> stuff only a NoClassDefFoundError... >>>>>> >>>>>> >>>>>> On Wed, Jul 16, 2014 at 10:49 PM, Remko Popma <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> I did think about that but if you look at the stack trace it is able >>>>>>> to load the Server class, so I think we're okay: >>>>>>> >>>>>>> java.lang.NoClassDefFoundError: >>>>>>> java.lang.management.ManagementFactory >>>>>>> at >>>>>>> org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:118) >>>>>>> at >>>>>>> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:369) >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Wed, Jul 16, 2014 at 10:41 PM, Gary Gregory < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> I do not think this is going to work. See my fix for the JNDI >>>>>>>> lookup loading. >>>>>>>> >>>>>>>> Because you have a hard reference in the LoggerContext class to our >>>>>>>> JMX Server class, you still have a dependency on JMX. We need to refer >>>>>>>> to >>>>>>>> our JMX Server class dynamically, using reflection for example. >>>>>>>> >>>>>>>> Gary >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: <[email protected]> >>>>>>>> Date: Wed, Jul 16, 2014 at 9:31 AM >>>>>>>> Subject: svn commit: r1611003 - in /logging/log4j/log4j2/trunk: >>>>>>>> log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java >>>>>>>> log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> src/changes/changes.xml >>>>>>>> To: [email protected] >>>>>>>> >>>>>>>> >>>>>>>> Author: rpopma >>>>>>>> Date: Wed Jul 16 13:31:07 2014 >>>>>>>> New Revision: 1611003 >>>>>>>> >>>>>>>> URL: http://svn.apache.org/r1611003 >>>>>>>> Log: >>>>>>>> LOG4J2-716: automatically disable log4j JMX when detecting we are >>>>>>>> running on Android >>>>>>>> >>>>>>>> Added: >>>>>>>> >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> (with props) >>>>>>>> Modified: >>>>>>>> >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java >>>>>>>> logging/log4j/log4j2/trunk/src/changes/changes.xml >>>>>>>> >>>>>>>> Modified: >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java >>>>>>>> URL: >>>>>>>> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java?rev=1611003&r1=1611002&r2=1611003&view=diff >>>>>>>> >>>>>>>> ============================================================================== >>>>>>>> --- >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java >>>>>>>> (original) >>>>>>>> +++ >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java >>>>>>>> Wed Jul 16 13:31:07 2014 >>>>>>>> @@ -41,6 +41,7 @@ import org.apache.logging.log4j.core.con >>>>>>>> import org.apache.logging.log4j.core.config.Reconfigurable; >>>>>>>> import org.apache.logging.log4j.core.jmx.Server; >>>>>>>> import org.apache.logging.log4j.core.util.Assert; >>>>>>>> +import org.apache.logging.log4j.core.util.Environment; >>>>>>>> import org.apache.logging.log4j.core.util.NetUtils; >>>>>>>> import org.apache.logging.log4j.message.MessageFactory; >>>>>>>> import org.apache.logging.log4j.spi.AbstractLogger; >>>>>>>> @@ -365,10 +366,12 @@ public class LoggerContext extends Abstr >>>>>>>> >>>>>>>> firePropertyChangeEvent(new PropertyChangeEvent(this, >>>>>>>> PROPERTY_CONFIG, prev, config)); >>>>>>>> >>>>>>>> - try { >>>>>>>> - Server.reregisterMBeansAfterReconfigure(); >>>>>>>> - } catch (final Exception ex) { >>>>>>>> - LOGGER.error("Could not reconfigure JMX", ex); >>>>>>>> + if (!Environment.isAndroid()) { // LOG4J2-716: Android has >>>>>>>> no java.lang.management >>>>>>>> + try { >>>>>>>> + Server.reregisterMBeansAfterReconfigure(); >>>>>>>> + } catch (final Exception ex) { >>>>>>>> + LOGGER.error("Could not reconfigure JMX", ex); >>>>>>>> + } >>>>>>>> } >>>>>>>> return prev; >>>>>>>> } >>>>>>>> >>>>>>>> Added: >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> URL: >>>>>>>> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java?rev=1611003&view=auto >>>>>>>> >>>>>>>> ============================================================================== >>>>>>>> --- >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> (added) >>>>>>>> +++ >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> Wed Jul 16 13:31:07 2014 >>>>>>>> @@ -0,0 +1,34 @@ >>>>>>>> +/* >>>>>>>> + * Licensed to the Apache Software Foundation (ASF) under one or >>>>>>>> more >>>>>>>> + * contributor license agreements. See the NOTICE file distributed >>>>>>>> with >>>>>>>> + * this work for additional information regarding copyright >>>>>>>> ownership. >>>>>>>> + * The ASF licenses this file to You 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 >>>>>>>> + * >>>>>>>> + * 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. >>>>>>>> + */ >>>>>>>> + >>>>>>>> +package org.apache.logging.log4j.core.util; >>>>>>>> + >>>>>>>> +/** >>>>>>>> + * Runtime environment-related utility methods. >>>>>>>> + */ >>>>>>>> +public final class Environment { >>>>>>>> + private Environment() { >>>>>>>> + } >>>>>>>> + >>>>>>>> + /** >>>>>>>> + * Returns {@code true} if we are running on Android, {@code >>>>>>>> false} otherwise >>>>>>>> + * @return {@code true} if system property >>>>>>>> "java.specification.vendor" contains "android" >>>>>>>> + */ >>>>>>>> + public static boolean isAndroid() { >>>>>>>> + return System.getProperty("java.specification.vendor", >>>>>>>> "x").toLowerCase().contains("android"); >>>>>>>> + } >>>>>>>> +} >>>>>>>> >>>>>>>> Propchange: >>>>>>>> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Environment.java >>>>>>>> >>>>>>>> ------------------------------------------------------------------------------ >>>>>>>> svn:eol-style = native >>>>>>>> >>>>>>>> Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml >>>>>>>> URL: >>>>>>>> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1611003&r1=1611002&r2=1611003&view=diff >>>>>>>> >>>>>>>> ============================================================================== >>>>>>>> --- logging/log4j/log4j2/trunk/src/changes/changes.xml (original) >>>>>>>> +++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed Jul 16 >>>>>>>> 13:31:07 2014 >>>>>>>> @@ -22,6 +22,9 @@ >>>>>>>> </properties> >>>>>>>> <body> >>>>>>>> <release version="?" date="2014-mm-dd" description="?"> >>>>>>>> + <action issue="LOG4J2-716" dev="popmarem" type="fix"> >>>>>>>> + Automatically disable log4j JMX when detecting we are >>>>>>>> running on Android. >>>>>>>> + </action> >>>>>>>> <action issue="LOG4J2-657" dev="popmarem" type="fix" >>>>>>>> due-to="Stefan Wehner"> >>>>>>>> Fixed AbstractDatabaseManager to close connection on >>>>>>>> writeInternal error. >>>>>>>> </action> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> E-Mail: [email protected] | [email protected] >>>>>>>> Java Persistence with Hibernate, Second Edition >>>>>>>> <http://www.manning.com/bauer3/> >>>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >>>>>>>> Spring Batch in Action <http://www.manning.com/templier/> >>>>>>>> Blog: http://garygregory.wordpress.com >>>>>>>> Home: http://garygregory.com/ >>>>>>>> Tweet! http://twitter.com/GaryGregory >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> E-Mail: [email protected] | [email protected] >>>>> Java Persistence with Hibernate, Second Edition >>>>> <http://www.manning.com/bauer3/> >>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >>>>> Spring Batch in Action <http://www.manning.com/templier/> >>>>> Blog: http://garygregory.wordpress.com >>>>> Home: http://garygregory.com/ >>>>> Tweet! http://twitter.com/GaryGregory >>>>> >>>> >>>> >>> >>> >>> -- >>> Matt Sicker <[email protected]> >>> >> >> >> >> -- >> E-Mail: [email protected] | [email protected] >> Java Persistence with Hibernate, Second Edition >> <http://www.manning.com/bauer3/> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >> Spring Batch in Action <http://www.manning.com/templier/> >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory >> > > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
